I have a script:
if(isset($_FILES['file_upload']) && $_FILES['file_upload']['error'] != 4) {
if(!file_exists('./Hier_je_files/'.$_FILES['file_upload']['name'])) {
if($_FILES['file_upload']['error'] > 0) {
echo '<script type="text/javascript">alert("'.$_FILES['file_upload']['error'].'")</script>';
} else {
chmod("./Hier_je_files/", 0755);
move_uploaded_file($_FILES["file_upload"]["tmp_name"], "./Hier_je_files/" . $_FILES["file_upload"]["name"]);
$_POST['bestand'] = $_FILES["file_upload"]["name"];
chmod("./Hier_je_files/".$_POST['bestand'], 0755);
}
} else {
echo '<script type="text/javascript">alert(\'Bestandnaam helaas bezet!\')</script>';
}
} else {
chmod("./Hier_je_files/".$_POST['bestand'], 0755);
}
And I get this error:
Warning: chmod() [function.chmod]: Operation not permitted in /home/remon/domains/remondb.eu/public_html/Handeler/control.php on line 347
Warning: move_uploaded_file(./Hier_je_files/download_r2.png) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/remon/domains/remondb.eu/public_html/Handeler/control.php on line 348
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpMuFzaS' to './Hier_je_files/download_r2.png' in /home/remon/domains/remondb.eu/public_html/Handeler/control.php on line 348
Warning: chmod() [function.chmod]: No such file or directory in /home/remon/domains/remondb.eu/public_html/Handeler/control.php on line 350
Warning: filesize() [function.filesize]: stat failed for ./Hier_je_files/download_r2.png in /home/remon/domains/remondb.eu/public_html/Handeler/control.php on line 358
By other people this script works fine, does my host blocks uploading or is the script bad?
The user that PHP is running as on your server does not have permission to use
chmod
. Consequently, you don't have permission to write to the file. You should probably not usechmod
in your script anyway, and it seems your host does not allow it.Rather, you should ensure that the folder you are attempting to upload to AND the folder that files upload to temporarily have the permissions you show above (0755).