468,247 Members | 1,324 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,247 developers. It's quick & easy.

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_testsql", $link)
or die ("Unable to select database");

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

$query = "INSERT INTO `media` VALUES ('','$filename','$filetype')";
$result = mysql_query($query);
$query = "SELECT * FROM `media` WHERE `filename` = '$filename'";
$result = mysql_query($query);
$newname = mysql_result($result,0,"id");
move_uploaded_file( $filetempname, "PLACE/".$newname.".dat");
mysql_close($link);
header( "location: PAGE.PHP" );
?>

ERROR:
Warning: move_uploaded_file(): 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

Apr 27 '06 #1
1 4242
NinJA999 wrote:
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_testsql", $link)
or die ("Unable to select database");

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

$query = "INSERT INTO `media` VALUES ('','$filename','$filetype')";
$result = mysql_query($query);
$query = "SELECT * FROM `media` WHERE `filename` = '$filename'";
$result = mysql_query($query);
$newname = mysql_result($result,0,"id");
move_uploaded_file( $filetempname, "PLACE/".$newname.".dat");
mysql_close($link);
header( "location: PAGE.PHP" );
?>

ERROR:
Warning: move_uploaded_file(): 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


http://www.php.net/manual/en/features.safe-mode.php
http://www.php.net/manual/en/feature....functions.php

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.
js*******@attglobal.net
==================
Apr 27 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Brian Richmond | last post: by
1 post views Thread by david | last post: by
2 posts views Thread by Christian Giordano | last post: by
4 posts views Thread by lawrence | last post: by
2 posts views Thread by Buddy Ackerman | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.