View Full Version : File upload issue

05-16-2008, 12:40 AM
I have a script running in the public_html/admin directory and It is trying to upload to the public_html/documents directory I have the following code:

$uploaddirurl = "http://uvfmusic.com/xpress/documents";

$resimadi = $_FILES['userfile']['name'];
$uploadfile ='"' . $uploaddir.'/'. $resimadi . '"';


move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir);

//$query = "INSERT INTO `files` (`id`,`file_name`,`file_path`,`tags`,`description`,`doc_name`,`genre`,`instrument`,`sounds_like`,`te mpo`) VALUES(NULL,'$resimadi','$uploaddirurl','$tags','$description','$doc_title','$genre','$instruments', '$sounds','$tempo')";
//echo $query;

//mysql_query($query) or die(mysql_error());
echo "<center><br><h1><a href=\"$uploaddir/$resimadi\">$resimadi</a> File was uploaded</h1><br><br><a href=\"javascript:history.go(-1);\"><< Back </a></center>\n";

It keeps throwing the following error:

Warning: move_uploaded_file(../documents): failed to open stream: Is a directory in /home/content/s/a/h/sahiaman/html/xpress/admin/doc_add.php on line 61

Warning: move_uploaded_file(): Unable to move '/tmp/php54FlTN' to '../documents' in /home/content/s/a/h/sahiaman/html/xpress/admin/doc_add.php on line 61

05-16-2008, 02:44 AM
The error message gives you a clue; you haven't used a closing slash, e.g. '../documents/' to indicate the path you want to move the file to. I would make sure you use the closing slash and you should consider using an absolute path (just in case PHP is attempting to move the file to /documents/ (under the '/' root path, one directory up from /tmp as indicated by ../documents/).