473,398 Members | 2,088 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,398 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 4383
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: 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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.