1

I keep getting the error:

Warning: copy(): open_basedir restriction in effect. File() is not within the allowed path(s): (/home/u590953899:/tmp:/var/tmp:/opt/php-5.5/pear) in /home/u590953899/public_html/upload_rename_ac.php on line 22

Line 22:

if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))

The entire code:

<?php

// Your file name you are uploading 
$file_name = $HTTP_POST_FILES['ufile']['name'];

// random 4 digit to add to our file name 
// some people use date and time in stead of random digit 
$random_digit=rand(0000,9999);

//combine random digit to you file name to create new file name
//use dot (.) to combile these two variables

$new_file_name=$random_digit.$file_name;

//set where you want to store files
//in this example we keep file in folder upload 
//$new_file_name = new upload file name
//for example upload file name cartoon.gif . $path will be upload/cartoon.gif
$path= "/cdn/uploads/".$new_file_name;
if($ufile !=none)
{
if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))
{
echo "Successful<BR/>"; 

//$new_file_name = new file name
//$HTTP_POST_FILES['ufile']['size'] = file size
//$HTTP_POST_FILES['ufile']['type'] = type of file
echo "File Name :".$new_file_name."<BR/>"; 
echo "File Size :".$HTTP_POST_FILES['ufile']['size']."<BR/>"; 
echo "File Type :".$HTTP_POST_FILES['ufile']['type']."<BR/>"; 
}
else
{
echo "Error";
}
}
?>

I searched Stack Overflow and google for some sort of answer but I could not find anything. This is really complicated, so how do I fix this?

  • 1
    `$HTTP_POST_FILES` has been deprecated a loooong time. You should use `$_FILES` and `move_uploaded_file()` instead. – jeroen Apr 08 '15 at 12:45
  • possible duplicate of [open\_basedir restriction in effect in Plesk for Windows](http://stackoverflow.com/questions/18403676/open-basedir-restriction-in-effect-in-plesk-for-windows) – Machavity Apr 08 '15 at 12:56
  • try this answer http://stackoverflow.com/questions/1846882/open-basedir-restriction-in-effect-file-is-not-within-the-allowed-paths/34980645#34980645 – yogihosting Jan 28 '16 at 19:22

0 Answers0