PHP writable issue with move_uploaded_file
After changing the file permissions to allow a picture upload I am now getting Internal Server Error and none of the following code is having a chance to execute. This all happened when I changed the file permissions of the folder /upload.
THE PHP
<?php
$filename = 'http://www.divethegap.com/update/z-images/admin/upload/test.gif';
if (is_writable($filename)) {
echo 'The file is writable';
} else {
echo 'The file is not writable';
}
print_r($_FILES);
if ($_FILES['thumbfile']['开发者_JAVA百科error'] === UPLOAD_ERR_OK) {
$info = getimagesize($_FILES['thumbfile']['tmp_name']);
if (($info[2] !== IMG_GIF) && ($info[2] !== IMG_JPEG)) {
die("not a gif/jpg");
}
if (filesize($_FILES['thumbfile']['tmp_name']) > 20000) {
die("larger than 20000");
}
move_uploaded_file($_FILES['thumbfile']['tmp_name'], 'http://www.divethegap.com/update/z-images/admin/upload/test.jpg');
echo '<script type="text/javascript">
parent.document.getElementById("thumbprogress").innerHTML = "Archiving"</script>Archiving';
}
else
{
echo '<script type="text/javascript">
parent.document.getElementById("thumbprogress").innerHTML = "Invalid File Format"</script>Invalid File Format';
}
?>
Currently the file permissions of the upload folder are open to all as writable.
Any ideas whats wrong?
Marvellous
You should upload to a local folder, not to an internet URL, ej:
$filename = '/var/www/my-site/z-images/admin/upload/test.gif';
精彩评论