Hi,
I use an upload script to allow visitors upload images to my web site.I recently wanted to use the chmod function,to chmod the uploaded files to 777,because by default the permissions of each file where set to 600.
Here's the upload script:
<?php
$path = "/files";
$max_size = 100000;
if (!isset($HTTP_POST_FILES['userfile'])) exit;
if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) {
if ($HTTP_POST_FILES['userfile']['size']>$max_size) { echo "Change file size."; exit; }
if (($HTTP_POST_FILES['userfile']['type']=="image/gif") || ($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/jpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/bmp") || ($HTTP_POST_FILES['userfile']['type']=="image/tiff")) {
if (file_exists($path . $HTTP_POST_FILES['userfile']['name'])) { echo "Change filename.<br>\n"; exit; }
$res = copy($HTTP_POST_FILES['userfile']['tmp_name'], $path .
$HTTP_POST_FILES['userfile']['name']);
if (!$res) { echo "TRansfer failed!<br>\n"; exit; } else { echo ""; }
} else { echo "Invalid filetype<br>\n"; exit; }
}
?>
Now I added this line:
chmod("$HTTP_POST_FILES['userfile']['name']",777)
to the end of the script,but i'm getting an error.
Can somebody help me?
thx