Uploading with PHP error

Thread Solved

Join Date: Feb 2006
Posts: 118
Reputation: mesamb1 is an unknown quantity at this point 
Solved Threads: 2
mesamb1's Avatar
mesamb1 mesamb1 is offline Offline
Junior Poster

Uploading with PHP error

 
0
  #1
Jun 18th, 2008
I am trying to write a simple php program that will up load files smaller then 200000000 bytes to my website, but I keep getting an error when I try to run it
the initial HTML code is:
  1. <html>
  2. <body>
  3.  
  4. <form action="upload.php" method="post"
  5. enctype="multipart/form-data">
  6. <label for="file">Filename:</label>
  7. <input type="file" name="file" id="file" />
  8. <br />
  9. <input type="submit" name="submit" value="Submit" />
  10. </form>
  11.  
  12. </body>
  13. </html>

and then the following is the php code:

[code]
<?php
if (($_FILES["file"]["size"] < 200000000))
{
if ($FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"] ["error"] . "<br />";
}
else
{
$Size = ($_FILES["files"]["size"]/ 1024);
if ($Size > 1000)
{
$Size= $Size/1000;
$type = "Mb";
}
else
{
$type= "Kb";
}

echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . $Size . " " . $type . "<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("stuff/" . $_FILES["file"] ["name"] ))
{
echo $_FILES["file"]["name"] . " already exist. ";
}
else
{


move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "stuff/" . $_FILES["file"] ["name"];
}
}
}
else
{
header("Location: http://www.doled.org/upload/uhuh.html");
}
?>
[\code]

which when I run on line gives me the error
"Upload: balloon08.gif
Type: image/gif
Size: 0 Kb
Temp file: /usr/local/tmp/phpe96Gqh

Warning: move_uploaded_file(upload/balloon08.gif) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/.aspen/mesamb1/doled.org/upload/upload.php on line 32

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/usr/local/tmp/phpe96Gqh' to 'upload/balloon08.gif' in /home/.aspen/mesamb1/doled.org/upload/upload.php on line 32
Stored in: stuff/balloon08.gif"

which makes no since to me and I would like to fix, any advice would be greatly appreciated
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 458
Reputation: khess is on a distinguished road 
Solved Threads: 8
Staff Writer
khess's Avatar
khess khess is offline Offline
Staff Writer

Re: Uploading with PHP error

 
0
  #2
Jun 19th, 2008
You need to look in your php.ini file and make sure you have a writeable directory for uploads. It is a temp directory for uploads to the server. On Linux, it is usually /tmp but can be almost anywhere that the web server has write access.

Change the php.ini and restart the web server.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 118
Reputation: mesamb1 is an unknown quantity at this point 
Solved Threads: 2
mesamb1's Avatar
mesamb1 mesamb1 is offline Offline
Junior Poster

Re: Uploading with PHP error

 
0
  #3
Jun 20th, 2008
I changed the name of the place on my server where I wanted the file to go and that seems to have done the trick, thanks for your help khess
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC