File Uplopder - Warning: open_basedir restriction in effect.

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply

Fri Oct 11, 2002 9:13 pm

Hi I am facing problem while uploading file. It gives me error -

Warning: open_basedir restriction in effect. File is in wrong directory in /usr/local/plesk/apache/vhosts/ on line 17

Please help me. I am giving my code also. Pl. help me...

if (isset($users_file)) {
echo "<B>Remote File Name:</B> $users_file<BR>";
echo "<B>Local File Name:</B> $users_file_name<BR>";
echo "<B>Local File Size:</B> $users_file_size<BR>";
if (isset($users_file_type)) {
echo "<B>Local File Type:</B> $users_file_type<P>"; }

// Change $doc_directory to your 'DocumentRoot'.
$doc_directory ="/usr/local/plesk/apache/vhosts/";
$my_file = "tmp/uploaded-".$users_file_name;
$copy_path =$doc_directory.$my_file;

if ($users_file != "none") {
if(!copy($users_file, $copy_path)) {
echo "File upload failed!"; }
else { ?><A HREF="<? echo $my_file; ?>">Upload Complete!</A>
<? } }
else { echo "<P>You must select a file to upload!<P>"; ?>
<A HREF="<? echo $PHP_SELF; ?>"><B>Back</B></A> to the Upload Form
<? } }

else { ?>
<form action="<? echo $PHP_SELF; ?>"
enctype="multipart/form-data" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="20000" />
<input type="file" name="users_file" /><br />
<input type="submit" value="Upload!" />
</form><? } ?>



Sat Oct 12, 2002 12:14 am

I'm not sure, but I think that you're not allowed to open a file on that location because of security reasons.
you will have to move uploaded files to a location where you can open them first, you will have to use the function move_uploaded_file for that.

Greetz Daan

Post Reply