473,406 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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 2175

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: matt | last post by:
I have compiled some code, some written by me, some compiled from various sources online, and basically i've got a very simple flat file photo gallery. An upload form, to upload the photos and give...
3
by: Bijoy Naick | last post by:
I've written a simple file upload user control in VB .NET. It comprises of an InputFile HTML Server Control, an Upload button and a message label. User clicks on the Browse button of the...
6
by: tshad | last post by:
I have an upload file input as: <input id="MyFile" style="width:300px" type="File" runat="Server"> This works fine, but I find that if my page doesn't pass validation during postback, the page...
18
by: Jen | last post by:
I'm using Microsoft's own VB.NET FTP Example: http://support.microsoft.com/default.aspx?scid=kb;en-us;832679 I can get the program to create directories, change directories, etc., but I can't...
4
by: Matt Jensen | last post by:
Howdy I've got a rather strange issue occuring. I used forms based .NET authentication, although I'm also setting some session variables when people login. However, I've found when people use...
5
by: William LaMartin | last post by:
I have a VB ASP.Net application where the user can upload a file using the FileUpload server control. I also want a thumbnail to be created for this file. Unfortunately I can see no means to...
4
by: riteshjain82 | last post by:
Hi, Please go through this: I am having a file (default.asp) on which i am taking many details from a user before mailing it to someone. I have also provided the user with a facility of...
6
by: Vic Spainhower | last post by:
Hello, I am trying to do a FTP file upload which works fine on my localhost but on my ISP server it fails. I can't seem to find where I can go to find the specific cause of the failure. In both...
7
by: pbd22 | last post by:
hi. i am having probs understanding how to grab a file being uploaded from a remote client. i am using hidden input fields for upload such as: <input id="my_file_element" type="file"...
1
by: pbd22 | last post by:
hi. i have been posting this here and elsewhere a lot and can't seem to get resolution on this problem. i have been trying to upload files using a hidden iframe to a asp.net/vb.net form. the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.