Page 1 of 1

Uploading Files Trouble

Posted: Tue Nov 04, 2003 8:43 pm
by DuFF
Ok, this is one of the wierdest things I've ever experienced with PHP. I was given free hosting by someone who I helped make a PHP script for. He needed an uploading script so I worked on it, tested it out on my domain and it worked. Then I gave it to him and now it gives this wierd error.

Warning: move_uploaded_file(): open_basedir restriction in effect. File(/submissions/installsubmissions.zip) is not within the allowed path(s): (/home/rctdload:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/rctdload/public_html/submissions.php on line 95

Now, I looked into open_basedir and basically what it does is restrict PHP from opening any files above a certain directory. This is one of safe_mode's options. It works whether safe_mode is on or not, so thats not the problem.

The wierdest thing is that both he and I are under the same account so we have exactly the same PHP.ini and are using the exact same PHP Script.
Heres the code near Line 95:

Code: Select all

<?php
        $uploaddir = "/submissions/";
        $filename=$_FILES['userfile']['name'];
        $filetemp=$_FILES['userfile']['tmp_name'];
        $dirfile = $uploaddir;
        $dirfile .= $fileoriginalname;
//...
if (is_uploaded_file($filetemp)){
        if (move_uploaded_file($filetemp,$dirfile))  //LINE 95
        {
//... removed irrelevant code

?>
Does anyone have any ideas?

Posted: Tue Nov 04, 2003 11:18 pm
by markl999
Try

Code: Select all

$uploaddir =$_SERVER['DOCUMENT_ROOT'].'/submissions/';
move_uploaded_file expects an absolute path not a relative one, so presuming /submissions is in your documentroot you should be ok.

Posted: Wed Nov 05, 2003 2:11 am
by m3mn0n
Yup. As stated here: [php_man]move_uploaded_file[/php_man] ...In the last comment. :)