erron Posted January 5, 2008 Share Posted January 5, 2008 hi guys hoping someone can help as my host is being no help at all. i have the following script which has been working for a few months now, suddenly it has started chmod'ing the directory 'productpics' instead of the file that is being uploaded. the file does exists and error checking finds that $fileonly is getting the correct name of the file but the script chmod's the directory to 644 and ignore the file. could this relate to a recent php upgrade by my host and a change of how it works? $uploaddir = '../productpics/'; $uploadfile = $uploaddir . basename($_FILES['file']['name']); $fileonly_t = $_FILES['file']['name']; $fileonly = urldecode("$fileonly_t"); if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) { chmod($fileonly, 0644); } any help would be much appreciated. Link to comment https://forums.phpfreaks.com/topic/84565-solved-chmod-problems/ Share on other sites More sharing options...
erron Posted January 5, 2008 Author Share Posted January 5, 2008 i should add also that when running the upload page i get the following error: "Warning: chmod() [function.chmod]: No such file or directory in /home/fieldsol/public_html/admin/addproduct_process.php on line 25" line 25 is the chmod funtion. Link to comment https://forums.phpfreaks.com/topic/84565-solved-chmod-problems/#findComment-430895 Share on other sites More sharing options...
Northern Flame Posted January 5, 2008 Share Posted January 5, 2008 try this: $uploaddir = '../productpics/'; $uploadfile = $uploaddir . basename($_FILES['file']['name']); $fileonly_t = $_FILES['file']['name']; $fileonly = urldecode("$fileonly_t"); imove_uploaded_file($_FILES['file']['tmp_name'], $uploadfile) if(file_exists($fileonly)){ chmod($fileonly, 0644); } else{ echo 'could not find '. $fileonly; } Link to comment https://forums.phpfreaks.com/topic/84565-solved-chmod-problems/#findComment-430898 Share on other sites More sharing options...
erron Posted January 5, 2008 Author Share Posted January 5, 2008 thanks, already did something similar to check file was found correctly and it was, i have now fixed the problem by giving the chmod a path from the script location: chmod("../productpics/$fileonly",0644); no idea why it has suddently required this after all this time but its now working. Link to comment https://forums.phpfreaks.com/topic/84565-solved-chmod-problems/#findComment-430903 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.