Dunno if it's just me, but you don't NEED the MAX_FILE_SIZE form item. I
never use it, I always define max file sizes and types in a separate
config file. My uploads work just fine.

Sorry, don't mean to nit pick :)

In your upload script, try defining where you actually want it copies to
as an absolute directory. Windows doesn't handle relative file copies
too well. It's caught me out on that a few times. TBH, not sure on all
the syntax, as I do things very differently... a lot simpler to be
honest...

Good luck...

chris kranz
fatcuban.com


-----Original Message-----
From: Stephen Edmonds [mailto:[EMAIL PROTECTED]] 
Sent: Monday, January 20, 2003 5: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" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
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_upload.
> 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




-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to