When I try to upload a file on my website I get the error :
Warning: chmod(): No such file or directory in /home/mattfh/public_html/upload.php on line 62
Here is the code around line 62.
// Upload the file
function do_upload() {
$temp_name = $_FILES['userfile']['tmp_name'];
$file_name = $_FILES['userfile']['name'];
$file_name = str_replace("\\","",$file_name);
$file_name = str_replace("'","",$file_name);
$file_path = UPLOAD_DIR.$file_name;
//File Name Check
if ($file_name =="") {
$message = "Invalid File Name Specified";
return $message;
}
$result = move_uploaded_file($temp_name, $file_path);
if (!chmod($file_path,0777))
$message = "change permission to 777 failed.";
else
$message = ($result)?"$file_name uploaded successfully. <br> To download the file refer people to this link <br><br> <a href='http://neowin.fh-net.com/files/$file_name'>Download</a><br> " :
"Somthing is wrong with uploading a file.";
return $message;
}
?>
Any help appreciated.