Use move_uploaded_file() instead of copy()
fr r wrote:
i'm trying to do a very simple thing:
upload image but it keep giving me this error although i gave permession on folder:
Warning: open_basedir restriction in effect. File is in wrong directory in /var/www/vhosts/negoumelshasha.com/httpdocs/test4.php on line 9
and here is my code:
//
HTMLBODY BGCOLOR=FF
?php
$uploadDir = $DOCUMENT_ROOT . /test/;
if (isset($submit))
{
if ($upload != 'none')
{
$dest = $uploadDir . $upload_name;
if (copy($upload, $dest))
{
echo Successfully uploaded $destBR\n;
}
else
{
echo FONT COLOR=FFBFile Upload Failed/B/FONTBR\n;
$perms = @fileperms($uploadDir);
$owner = @fileowner($uploadDir);
if (!$perms)
{
echo Directory does not exist: $uploadDirBR\n;
}
else
{
$myuid = getmyuid();
if (!($perms 2) !(($owner == $myuid) ($perms 128)))
{
echo get_current_user(), doesn't have permission to write in $uploadDirBR\n;
}
}
}
}
else
{
echo FONT COLOR=FFBFile2 Upload Failed/B/FONTBR\n;
echo Filesize exceeds limit in FORM or php.iniBR\n;
}
}
?
FORM ENCTYPE=multipart/form-data ACTION=test4.php METHOD=POST
INPUT TYPE=HIDDEN NAME=MAX_FILE_SIZE VALUE=1
Upload File: INPUT NAME=upload TYPE=FILEBR
INPUT TYPE=SUBMIT NAME=submit VALUE=Upload
/FORM
/BODY/HTML
-
Do you Yahoo!?
Free online calendar with sync to Outlook(TM).
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php