Page 1 of 1

move_uploaded_file destination string missing delimiter

Posted: Wed Nov 26, 2008 5:30 pm
by mophilly
When I attempt to upload a file, PHP raises this error:

Code: Select all

SYSTEM WARNING: move_uploaded_file(/opt/mantis/uploads36eed9c6b5deeaaf696fb9cbf1a7a636): failed to open stream: Permission denied
 
SYSTEM WARNING: move_uploaded_file(): Unable to move '/tmp/phpiV06Ye' to '/opt/mantis/uploads36eed9c6b5deeaaf696fb9cbf1a7a636'
Note the destination string. I believe it missing the trailing slash after the word "uploads", e.g.
'/opt/mantis/uploads/36eed9c6b5deeaaf696fb9cbf1a7a636'

In the Apache <directory> directive I have the following php value assignments:

Code: Select all

php_admin_value open_basedir /opt/mantis/:/tmp/
php_admin_value upload_tmp_dir /opt/mantis/uploads/
In php.ini, uploads are enabled, the max file size is 50M, and memory limit is 64MB. The "mantis" settings are agreeable with the php.ini. The "uploads" directory is set to 776 (drwxrw-rw)

What do I need to adjust and/or learn to resolve this?

TIA.

Re: move_uploaded_file destination string missing delimiter

Posted: Fri Nov 28, 2008 4:46 am
by nnnpuri
// File Upload Valditation...

if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/bmp")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000))
{
if ($_FILES["file"]["error"] >20000)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{


if (file_exists("D:/Training/12.11.08/images/" . $_FILES["file"]["name"]))
{


$now = time();

$path_parts = pathinfo($_FILES["file"]["name"]);
$string="naresh";
$newtry=$path_parts['basename'].$string;

$imagestring=$_FILES["file"]["name"];
$shuffled = str_shuffle($imagestring);

move_uploaded_file($_FILES["file"]["tmp_name"],
"D:/Training/12.11.08/images/" .$newtry.$now.$shuffled.$_FILES["file"]["name"]);
echo "Image Stored in: " ."D:/Training/12.11.08/images/"."<br>".$newtry.$now.$shuffled. $_FILES["file"]["name"];
}

else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"D:/Training/12.11.08/images/" . $_FILES["file"]["name"]);
echo "Image Stored in: " ."D:/Training/12.11.08/images/"."<br>". $_FILES["file"]["name"];
}
}
}

else
{
//echo "Invalid file"."<br>";
$infileerror="invalid file";
}

Re: move_uploaded_file destination string missing delimiter

Posted: Fri Nov 28, 2008 1:11 pm
by airy
Please check this :
'/opt/mantis/uploads36eed9c6b5deeaaf696fb9cbf1a7a636'

Suppose to be

'/opt/mantis/uploads/36eed9c6b5deeaaf696fb9cbf1a7a636'

What's more : You should make sure directory /opt and /opt/mantis is accessable too

Re: move_uploaded_file destination string missing delimiter

Posted: Sat Nov 29, 2008 8:34 am
by nnnpuri
you may have write wronge path to store file