472,786 Members | 1,415 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,786 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 2136

"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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.