| | |
Uploading with PHP error
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
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:
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
the initial HTML code is:
PHP Syntax (Toggle Plain Text)
<html> <body> <form action="upload.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" /> <br /> <input type="submit" name="submit" value="Submit" /> </form> </body> </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
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.
Change the php.ini and restart the web server.
![]() |
Similar Threads
- how to retrive image file from mysql databse using php (PHP)
- syntax error, unexpected $end in ndex.php on line 127 (PHP)
- Parse error: syntax error, unexpected $end (PHP)
- Parse error, unexpected T_STRING, expecting T_CASE (PHP)
- php uploader script (PHP)
- Uploading current php site to another site. (PHP)
- Cannot find server or DNS Error (Web Browsers)
- Help, If You Can Find My Error! Exhausted Again (PHP)
- Parse Error in PHP (PHP)
- Page cannot be displayed Cannot find server or DNS Error (Web Browsers)
Other Threads in the PHP Forum
- Previous Thread: Form in one iFrame refreshes another iFrame
- Next Thread: how can I track "post" varaible thru 3-rd party shopping-cart
| Thread Tools | Search this Thread |
5.2.10 action apache api array beginner beneath binary broken cakephp checkbox class classes cms code cron curl database date destroy display dynamic echo echo$_get[x]changingitintovariable... email encode error fcc file files folder form forms function functions google header howtowriteathesis href htaccess html image images include insert ip javascript joomla limit link local login mail memberships menu mlm mod_rewrite multiple multipletables mysql mysqlquery neutrality oop open passwords paypal pdf php provider query radio random record remote rss script search server sessions sockets source space sql strip_tags syntax system table template thesishelp tutorial update upload url validator variable video voteup web window.onbeforeunload=closeme; youtube





