468,256 Members | 1,410 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,256 developers. It's quick & easy.

PHP File Upload Problem

I have a problem uploading files with PHP which has me stumped! I am unable
to successfully upload files. My simple test script is as follows:

<?php

if (count($_FILES))
{
var_dump($_FILES) ;
}

if (is_uploaded_file($_FILES['toProcess']['tmp_name']))
{
print "<h3>File successfully upload.</h3>" ;
print "<a href=\"{$_SERVER['PHP_SELF']}\">Try again?<br>" ;
}
else
{
print <<< __RAWHTML__
<form enctype="multipart/form-data" action="{$_SERVER['PHP_SELF']}"
method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="10240000">
Filename: <input name="toProcess" type="file">
<input type="submit" value="upload">
</form>
__RAWHTML__;
print "<br><a href=\"{$_SERVER['PHP_SELF']}\">Try again?<br>" ;
}

?>
When I run it I get the following back:

array(1) { ["toProcess"]=> array(5) { ["name"]=> string(12) "100_2038.JPG"
["type"]=> string(0) "" ["tmp_name"]=> string(0) "" ["error"]=> int(1)
["size"]=> int(0) } }

Obviously I have some sort of error as my "tmp_name" key is null and the
"error" key is 1.

Any ideas or suggestions? I am running IIS with PHP 4.3.4. I checked my
php.ini file and the settings for uploading files look good to me:

;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;

; Whether to allow HTTP file uploads.
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default if
not
; specified).
upload_tmp_dir = c:\windows\temp

; Maximum allowed size for uploaded files.
upload_max_filesize = 1G

Thanks for any help or suggestions.

Mike
--
Mike Walsh - mike_walsh at mindspring.com
Jul 17 '05 #1
3 2012

"Mike Walsh" <mi********@mindspring.com> wrote in message news:0%ald.9258

[ ... snipped ... ]

; Maximum allowed size for uploaded files.
upload_max_filesize = 1G


[ ... snipped ... ]

It turns out that 1G is not a valid value for this directive. Not sure why
I haven't run into this problem previously but setting it to a "megabyte"
value solves my problem.

Mike

--
Mike Walsh - mike_walsh at mindspring.com
Jul 17 '05 #2
Since my server doesn't carry php.general I'm posting only
to c.l.php.

Mike Walsh wrote:
"Mike Walsh" <mi********@mindspring.com> wrote
upload_max_filesize = 1G


It turns out that 1G is not a valid value for this directive.


Right. The shorthand notations are listed in PHP.net's FAQ
as upper- or lowercase 'K' and 'M', where '1K' equals 1024
bytes and '1M' equals 1048576 bytes. '1G' equals 1 byte!

<http://www.php.net/manual/en/faq.using.php#faq.using.shorthandbytes>
Not sure why I haven't run into this problem previously but
setting it to a "megabyte" value solves my problem.


I don't see that unit listed anywhere; it isn't mentioned in
the docs for file upload configuration options.

http://www.php.net/manual/en/ini.sect.file-uploads.php

HAGW!

--
Jock
Jul 17 '05 #3

"John Dunlop" <us*********@john.dunlop.name> wrote in message
[ ... snipped .. ]
Not sure why I haven't run into this problem previously but
setting it to a "megabyte" value solves my problem.


I don't see that unit listed anywhere; it isn't mentioned in
the docs for file upload configuration options.

[ ... snipped ...]

I should have been more clearer. I used the "M" notation to set my desired
value in megabytes.

Mike

--
Mike Walsh - mike_walsh at mindspring.com
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by matt | last post: by
3 posts views Thread by Bijoy Naick | last post: by
6 posts views Thread by tshad | last post: by
5 posts views Thread by William LaMartin | last post: by
6 posts views Thread by Vic Spainhower | last post: by
7 posts views Thread by pbd22 | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.