file upload woes


#1

I’ve been trying to fiugure out how to upload files with php with the help of online tutorials and php.net, but have been unable to get any of the examples to work…

my web server is set up with IIS (v.5 I believe).
few relevant ini values:

[ul]file_uploads = On
upload_tmp_dir = C:PHPuploadtemp
upload_max_filesize = 2M
so is register globals…[/ul]

and of course, my code :smiley:

-g

edit: why can’t I get the php code tags to work??? :roll:


#2

sorry forgot!

this is the result of running the above script:

Warning: move_uploaded_file(/uploads/gyby_1790_12427313.jpg): failed to open stream: No such file or directory in c:inetpubwwwrootentelesiscpgetfile.php on line 18

Warning: move_uploaded_file(): Unable to move ‘C:PHPuploadtempphpFF.tmp’ to ‘/uploads/gyby_1790_12427313.jpg’ in c:inetpubwwwrootentelesiscpgetfile.php on line 18
Possible file upload attack! Here’s some debugging info:
Array
(
[userfile] => Array
(
[name] => gyby_1790_12427313.jpg
[type] => image/pjpeg
[tmp_name] => C:PHPuploadtempphpFF.tmp
[error] => 0
[size] => 44366
)

)

:-?

#3

Make sure the upload folder exists and the file you are trying to upload is under 2M.


#4

well the temp directory (C:PHPuploadtemp) exists, as does the relative directory (/uploads/)…

and “gyby_1790_12427313.jpg” in the warning message is the file I’m trying to upload… under 2mb. :)


#5

Hum, if the path is relative, you shouldn’t place a / before the first folder (that leads to the root)


#6

Try using the full server path to your ‘uploads’ directory:

$uploaddir = ‘/home/serverpath/uploads/’;

Also make sure that your ‘uploads’ directory is world writeable. ie chmod it to 777.


#7

changed to:

$uploaddir = ‘/inetpub/wwwroot/sitename/cp/upload/’;

should I use ‘localhost’, or ‘c:/’ or the actual server name before inetpub?

Also make sure that your ‘uploads’ directory is world writeable. ie chmod it to 777.<

can not the windows web permissions thing do the same? I hadn’t changed anything before posting my problem, however now that I have given read, write, script source access, and directory browsing access permissions, I still cannot upload files… I no longer get the warnings however, though they were remedied quite a while ago; something entiely unrelated to the upload problem…

btw, how does one chmod a directory in windows? sorry so many questions… :lol:

g-


#8

well now it gets weird… :-?

thanks again, :-?


#9
how does one chmod a directory in windows? sorry so many questions

I believe the chmod function is only applicable to a Linux server. I have never used a windows server, only Apache, so I can`t really give you good sound advice as to which is best. You need someone to reply who has used both servers.


#10

finally it has been solved! :smiley: I had played with changing and indeed removing it before, but all without having the right permissions set for the folder…

btw, thanks for the chmod advice; that set me on the right path! :wink:

lol now I can go stop the apache download!

g-


#11

Glad you got it sorted. Nothing like the relief you get when something finally works.

:)