473,237 Members | 1,184 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,237 software developers and data experts.

How to read uploaded file in chunks using PHP?

Don
Hi all,

I need to read an uploaded file into chunks, so I can examine the acculative size between chunks to
determine if a maximum size is being exceeded. I'm currently using the PHP function
"move_uploaded_file()" to move it in one piece. But, I'm finding some clients files are bigger than
I want to allow, and with that function I don't have an opportunity to determine that until the
entire file has been uploaded.

Thanks for any help.
Don

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Jul 17 '05 #1
2 4370
Don <no@adr.com> wrote:
I need to read an uploaded file into chunks, so I can examine the
acculative size between chunks to determine if a maximum size is being
exceeded. I'm currently using the PHP function "move_uploaded_file()"
to move it in one piece. But, I'm finding some clients files are
bigger than I want to allow, and with that function I don't have an
opportunity to determine that until the entire file has been uploaded.


AFAIK this is not possible with PHP (only).

Jul 17 '05 #2
NC
Don wrote:

I need to read an uploaded file into chunks, so I can examine
the acculative size between chunks to determine if a maximum
size is being exceeded.


No you don't. To limit the maximum size of an upload, you can simply
set proper values for upload_max_filesize and post_max_size
configuration
directives and check the value of $_FILES['form_field']['error'] after
the upload. If if is equal to UPLOAD_ERR_INI_SIZE constant (or,
numerically, 1), you can delete the file from the temporary directory
and tell the user to control his uploading appetites.

An alternative is to specify a MAX_FILE_SIZE field in the upload form
and compare the value of $_FILES['form_field']['error'] with
UPLOAD_ERR_FORM_SIZE (or 2).

For more information, see:

http://www.php.net/features.file-upload
http://www.php.net/features.file-upload.errors

Cheers,
NC

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: ZafT | last post by:
Thanks in advance for any tips that might get me going in the right direction. I am working on a simple exercise for school that is supposed to use read to read a file (about 10 MB). I am...
3
by: KWienhold | last post by:
I'm currently writing an application (using Visual Studio 2003 SP1 and C#) that stores files and additional information in a single compound file using IStorage/IStream. Since files in a compound...
12
by: Sean Davis | last post by:
I am working on a simple script to read from one database (oracle) and write to another (postgresql). I retrieve the data from oracle in chunks and drop the data to postgresql continuously. The...
6
by: ericunfuk | last post by:
Hi ALL, I want to read a binary file(it's pic.tif file, I guess it's binary file?), then write it to a new file), I have several questions about this process: When I use fread() to read a...
0
by: ttamilvanan81 | last post by:
Hai, I am doing a Struts application. In this application, i need to read a dbf file(foxpro database file) and it will be write to the SQL Server 2005. The application administrator will be...
2
by: syam | last post by:
Hai evenerybody.. I uploaded a text/html file into the database now i want to read the contents of the file and write the contents to send as an email. How do i read the contents of the file,...
4
by: Ross | last post by:
Hello, I am trying to Read and Write to a text file on a web server using Microsoft Visual Basic 2005 Express Edition. So far I have managed to complete my testing with a local text file using...
0
by: Dom Rout | last post by:
Hello. Well, this is my first post on any USENET group anywhere, so I hope I get it right. Basically, I just want to get some opinions on a plan of mine for a new project. I want to produce a...
28
by: tlpell | last post by:
Hey, read some tips/pointers on PHP.net but can't seem to solve this problem. I have a php page that reads the contents of a file and then displays the last XX lines of the file. Problem is...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.