I made a website a couple of year ago which has worked fine till now.
now, when I try to load an image from the backend it raises me some warning and the Image fails to be moved in the destination directory.
here is the warning I get
Warning: move_uploaded_file(path/image_name.jpg): failed to open stream: Permission denied in D:\inetpub\websemote_directory\php_script_name.php on line 184
Warning: move_uploaded_file(): Unable to move 'C:\PHPVersions\PHP55\uploadtemp\php418A.tmp' to 'path/image_name.jpg' in D:\inetpub\websemote_directory\php_script_name.php on line 184
here is the line giving me the warning
if (!move_uploaded_file($_FILES['img_'.$pos]['tmp_name'], 'path/'."part_of_image_name".$_FILES['img_'.$pos]['name'])) {
$msg = "<p>Error loading image!!</p>";
break;
}
it does not even print the error message.
I tried to change permissions on directory (and all subdirs and files) via ftp but I'm not sure it succeded because it was giving me the following message
Comando: SITE CHMOD 740 Photo4.jpg.
Risposta: 500 'SITE': command not understood
(by the way I read somewhere that it does not fix the problem. However the guy said he solved by using some magic which is not working for me - or I'm misunderstanding how to do it)
Everything worked until a few days/weeks ago (the customer wasn't clear on that point) so I just wanted to know if this is a kind of known issue or what (and a possible solution), since after a littlebit of research I could not find anything usefull.
Found out to solve the problem by using the control panel of site hosting provider to change manually permissions on directory.
try this, but first create a directory named uploads in the root directory:
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}