Jump to content

Recommended Posts

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

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.