RE: [PHP-WIN] Moving an uploaded file keeps failing
| From: | Matt Babineau | Date: | Mon, 20 Jan 2003 17:32:58 +0000 |
| Subject: | RE: [PHP-WIN] Moving an uploaded file keeps failing | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-17994@lists.php.net to get a copy of this message | ||
Thanks Stephen, I'll try this out now!
--> -----Original Message-----
--> From: Stephen Edmonds [mailto:stephen.edmonds5@btinternet.com]
--> Sent: Monday, January 20, 2003 12:26 PM
--> To: Matt Babineau
--> Cc: PHP Windows Helplist
--> Subject: Re: [PHP-WIN] Moving an uploaded file keeps failing
-->
-->
--> Currently from what I can see there are a few problems:
-->
--> The Form:
-->
--> <form enctype="multipart/form-data" action="<? echo
--> $_SERVER['SCRIPT_NAME'];?>" method="post"> Send this file:
--> <input name="userfile" type="file"> <input
type="submit"
--> value="Send File"> </form>
-->
--> action is not essential if the form is sending to itself
--> (okay, maybe thats just me being lazy :p). However, you
--> missed out a vital field
-->
--> <input type="hidden" name="MAX_FILE_SIZE" value="Maximum
--> file size in bytes">
-->
--> This needs to appear just before the file upload input. It
--> tells PHP what the biggest size of file to accept is.
--> Without it, no file will be uploaded! Remember to change
--> the value to an actual number
-->
--> Upload Script
-->
--> You should be using $_FILES array when uploading a file.
-->
--> $_FILES["userfile"]["name"] - Orginal name of the file
--> uploaded, given by the user
-->
--> $_FILES["userfile"]["error"] - Variable that contains an
--> error report. If something goes wrong, a number will get
--> put in here. 0 - Upload was okay 1 - The uploaded file
--> exceeds the upload_max_filesize directive in php.ini. 2 -
--> The uploaded file exceeds the MAX_FILE_SIZE directive that
--> was specified in the html form. 3 - The uploaded file was
--> only partially uploaded 4 - No file was uploaded
-->
--> $_FILES["userfile"]["tmp_name"] - This contains the
--> location and name of the file which was uploaded
-->
--> $_FILES['userfile']['type'] - The type of file that was
--> uploaded (See link below for more info!)
-->
--> $_FILES['userfile']['size'] - The size of the newly uploaded file
-->
--> For more infomation visit
--> http://www.php.net/manual/en/features.file-upload.php
-->
--> It is important to check the error number before you try to
--> move the file. Also, rather than checking for 'post', check
--> for $_FILES['userfile']['name']
-->
--> If you still have problems, email the list again with your
--> error message/code. Good luck
-->
--> Stephen
-->
-->
--> ----- Original Message -----
--> From: "Matt Babineau" <matt@criticalcode.com>
--> To: <php-windows@lists.php.net>
--> Sent: Monday, January 20, 2003 4:55 PM
--> Subject: [PHP-WIN] Moving an uploaded file keeps failing
-->
-->
--> > Here is the error:
--> >
--> > PHP Warning: move_uploaded_file(/) [function.move-uploaded-file
--> > <http://www.php.net/function.move-uploaded-file>
]:
--> failed to create
--> > stream: No such file or directory in
--> >
--> D:\wwwroot\kingmanchamber\secure-area\administration\upload\
--> file_uploa
--> > d.
--> > php on line 22 PHP Warning: move_uploaded_file()
--> > [function.move-uploaded-file
--> > <http://www.php.net/function.move-uploaded-file>
]: Unable to move
--> > 'd:\Temp\php443.tmp' to '/' in
--> >
--> D:\wwwroot\kingmanchamber\secure-area\administration\upload\
--> file_upload.
--> > php on line 22
--> >
--> > Here is the code:
--> >
--> > <form enctype="multipart/form-data" action="<? echo
--> > $_SERVER['SCRIPT_NAME'];?>" method="post"> Send this
file: <input
--> > name="userfile" type="file"> <input type="submit"
--> value="Send File">
--> > </form>
--> >
--> > <?
--> > if ($_SERVER['REQUEST_METHOD'] == "POST") {
--> > echo $_FILES['userfile']['name'] . "<BR>";
--> > echo $_FILES['userfile']['tmp_name'] . "<BR>";
--> >
--> > move_uploaded_file($_FILES['userfile']['tmp_name'], "/");
--> >
--> > }
--> > ?>
--> >
--> > I am running this on a winxp pro machine iis 5.1, php
--> 4.3.0 running as
--> > a CGI.
--> >
--> > This code is pretty much from the PHP.net site, so I am a
--> tad baffled
--> > on this one.
--> >
--> > -Matt
--> >
-->
-->
-->
--> --
--> PHP Windows Mailing List (http://www.php.net/)
--> To unsubscribe, visit: http://www.php.net/unsub.php
-->
-->