NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP MySQL File Upload Help

Peter Sawczynec ps at pswebcode.com
Wed Apr 26 19:47:53 EDT 2006


>From php.net: 
 
Note: move_uploaded_file() is both safe
<http://us2.php.net/manual/en/features.safe-mode.php#ini.safe-mode> mode and
open_basedir
<http://us2.php.net/manual/en/features.safe-mode.php#ini.open-basedir>
aware. 
 
Peter

-----Original Message-----
From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org] On
Behalf Of Nick Aldwin
Sent: Wednesday, April 26, 2006 7:25 PM
To: talk at lists.nyphp.org
Subject: [nycphp-talk] PHP MySQL File Upload Help


I have the following code to handle file uploads.  There is a database
called "media".  The errors 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" );
?>

Warning: move_uploaded_file(PLACE/8.dat): failed to open stream: No such
file or directory in BLAHBLAH/upload.php on line 17

Warning: move_uploaded_file(): Unable to move '/tmp/phpD4xBiO' to
'mnestuffz/8.dat' in BLAHBLAH/upload.php on line 17

Warning: Cannot modify header information - headers already sent by (output
started at BLAHBLAH/upload.php:17) in BLAHBLAH/upload.php on line 19

-- 
Nick Aldwin
NJAldwin at gmail.com  <mailto:NJAldwin at gmail.com> 
http://www.nictitatingrabbit.com 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20060426/f0faf9f4/attachment.html>


More information about the talk mailing list