file upload error
hi, ive used this method many times before to upload pictures to a folder on my remote host but this time it aint wrkin!
this is the error i get: -
Warning: Unable to create 'upload_files/tentphoto2.jpg': Permission denied in /www.classicjoineryweb.co.uk/upload.php on line 75
{line 74,75,76 shown below)
Warning: Unable to move '/tmp/phpBvZc1i' to 'upload_files/tentphoto2.jpg' in /www.classicjoineryweb.co.uk/upload.php on line 75
Somthing is wrong with uploading a file.
heres the lines of upload code i use: -
<?php
$site_name = $_SERVER['HTTP_HOST'];
$url_dir = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
$url_this = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
$upload_dir = "upload_files/";
$upload_url = $url_dir."/upload_files/";
$message ="";
//create upload_files directory if not exist
//If it does not work, create on your own and change permission.
if (!is_dir("upload_files")) {
die ("upload_files directory doesn't exist");
}
if ($_FILES['userfile']) {
$message = do_upload($upload_dir, $upload_url);
}
else {
$message = "Invalid File Specified.";
}
print $message;
function do_upload($upload_dir, $upload_url) {
$temp_name = $_FILES['userfile']['tmp_name'];
$file_name = $_FILES['userfile']['name'];
$file_type = $_FILES['userfile']['type'];
$file_size = $_FILES['userfile']['size'];
$result = $_FILES['userfile']['error'];
$file_url = $upload_url.$file_name;
$file_path = $upload_dir.$file_name;
//File Name Check
if ( $file_name =="") {
$message = "Invalid File Name Specified";
return $message;
}
//File Size Check
else if ( $file_size > 500000) {
$message = "The file size is over 500K.";
return $message;
}
//File Type Check
else if ( $file_type == "text/plain" ) {
$message = "Sorry, You cannot upload any script file" ;
return $message;
}
:)line 73
$result = move_uploaded_file($temp_name, $file_path);
$message = ($result)?"File url <a href=$file_url>$file_url</a>" :
"Somthing is wrong with uploading a file.";
:)line 76
return $message;
}
?>
any ideas why im getting these errors?
ive got a feeling it could be somthing to do with the permissions ive got to my server and to uploading stuff to it? dont see why i would havre any problems though?!
cheers
ASH
__________________
My new web design domain
www.askmultimedia.co.uk
|