PHP File Upload Restriction?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • NinJA999

    PHP File Upload Restriction?

    I have the following code to handle file uploads. There is a database
    called "media". The error I keep getting will follow the code. The
    upload data gets into the database fine; it seems to be storing the
    file that causes a problem. Please help!

    <?php
    $link = mysql_connect ( "localhost" , "ninja999_tsql" , "MYPASS")
    or die("Can't connect to database server");

    mysql_select_db ("ninja999_test sql", $link)
    or die ("Unable to select database");

    $filetempname=$ _FILES['file']['tmp_name'];
    $filename=$_FIL ES['file']['name'];
    $filetype=$_FIL ES['file']['type'];

    $query = "INSERT INTO `media` VALUES ('','$filename' ,'$filetype')";
    $result = mysql_query($qu ery);
    $query = "SELECT * FROM `media` WHERE `filename` = '$filename'";
    $result = mysql_query($qu ery);
    $newname = mysql_result($r esult,0,"id");
    move_uploaded_f ile( $filetempname, "PLACE/".$newname.".da t");
    mysql_close($li nk);
    header( "location: PAGE.PHP" );
    ?>

    ERROR:


    Warning: move_uploaded_f ile(): open_basedir restriction in effect.
    File(PLACE/9.dat) is not within the allowed path(s): (BLAHBLAH/tmp) in
    BLAHBLAH/upload.php on line 17

  • Jerry Stuckle

    #2
    Re: PHP File Upload Restriction?

    NinJA999 wrote:[color=blue]
    > I have the following code to handle file uploads. There is a database
    > called "media". The error I keep getting will follow the code. The
    > upload data gets into the database fine; it seems to be storing the
    > file that causes a problem. Please help!
    >
    > <?php
    > $link = mysql_connect ( "localhost" , "ninja999_tsql" , "MYPASS")
    > or die("Can't connect to database server");
    >
    > mysql_select_db ("ninja999_test sql", $link)
    > or die ("Unable to select database");
    >
    > $filetempname=$ _FILES['file']['tmp_name'];
    > $filename=$_FIL ES['file']['name'];
    > $filetype=$_FIL ES['file']['type'];
    >
    > $query = "INSERT INTO `media` VALUES ('','$filename' ,'$filetype')";
    > $result = mysql_query($qu ery);
    > $query = "SELECT * FROM `media` WHERE `filename` = '$filename'";
    > $result = mysql_query($qu ery);
    > $newname = mysql_result($r esult,0,"id");
    > move_uploaded_f ile( $filetempname, "PLACE/".$newname.".da t");
    > mysql_close($li nk);
    > header( "location: PAGE.PHP" );
    > ?>
    >
    > ERROR:
    >
    >
    > Warning: move_uploaded_f ile(): open_basedir restriction in effect.
    > File(PLACE/9.dat) is not within the allowed path(s): (BLAHBLAH/tmp) in
    > BLAHBLAH/upload.php on line 17
    >[/color]

    PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.

    PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.


    Check the directory you're trying to write the file to actually exists, is in a
    directory tree allowed by open_basedir (see php_info()) and has the same owner
    as the Apache process.


    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    Working...