Upload is still not working

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,
  I have some problems for upload file script. The script generated a
lot of permission denied error msg. I have changed the upload dir and
its parent dir into 777. I am quite sure I did the permission settings
right.

I have attached the error msg and my testing source code with this email

Anyone can help me .

Thanks!

yours,
Michael

My Error Msg: 

Warning: move_uploaded_file(upload_files/Blue hills.jpg)
[function.move-uploaded-file]: failed to open stream: Permission
denied in /var/www/html/simple_upload.php on line 47

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to
move '/tmp/phpvdnBbQ' to 'upload_files/Blue hills.jpg' in
/var/www/html/simple_upload.php on line 47
Somthing is wrong with uploading a file.

My Testing Code:
<?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/";
$message ="";


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;
    }

    $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.";

    return $message;
}
?>
<form name="upload" id="upload" ENCTYPE="multipart/form-data" method="post">
  Upload Image<input type="file" id="userfile" name="userfile">
  <input type="submit" name="upload" value="Upload">
</form>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux