Forum Moderators: coopster

Message Too Old, No Replies

File Upload Permisson Probs

         

dc_duo

11:52 am on Sep 8, 2004 (gmt 0)

10+ Year Member



Hello just trying to add uploads to my website. I have just started by writing this code and seeing if the files will get moved before finishing the rest of my scripting however when I submit the form I get the following messages

Warning: move_uploaded_file(../uploads/): failed to open stream: Permission denied in C:\webserv\nduk\webroot\insertdata.php on line 204

Warning: move_uploaded_file(): Unable to move 'C:\PHP\uploadtemp\php54.tmp' to '../uploads/' in C:\webserv\nduk\webroot\insertdata.php on line 204

I am using XP and have tried to set permissons through the propities panel but to be honest I dont know what I really fidding with I changed the web site sharing to read and write permissons but still no joy can anyone help? the code I wrote is below. The name image is the one submitted in the form.

if (move_uploaded_file($_FILES['image']['tmp_name'], "../uploads/{$FILES['image']['name']}")) {

print '<p><font color="red">The file has been uploaded</font></p>';

} else {

print '<p>The file could not be moved because </p>';

$img_name = 'noimage.jpg' ;

}

dreamcatcher

4:27 pm on Sep 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Looks like you need to CHMOD your 'uploads' dir to 777. You should be able to do this in your website control panel. Some FTP programs also let you change the permissions, such as WS_FTP.

Also, you should use the is_uploaded_file() function to test if a file has been uploaded before you move it.


if (is_uploaded_file($_FILES['image']['tmp_name']))
{

//move file

}

dc_duo

7:59 pm on Sep 9, 2004 (gmt 0)

10+ Year Member



One more question I removed the folder called "uploads" from my direcroty and run the script again this time it work creating a file called uploads.

Does this file store all the information here for every upload added or is it overwritten with the new file uploaded when a picture is submitted?

Please could you help?