Tom
Tom

Reputation: 3044

Can I limit upload size in PHP but still receive truncated files?

I would like people to upload any size file to my site but I need only first 1 kB of it. So I would like PHP to somehow stop receiving a file after it got this 1 kB and then just process this truncated file.

Upvotes: 0

Views: 105

Answers (2)

Tamás Szabó
Tamás Szabó

Reputation: 348

Version 2. If you cant do it with basic php support, then:

Create a new php, with a tcp socket server. Start the socket on another port, for example 8080, and that will handle your file upload.

You wait for start of the content (trim headers, and other unneeded data.), and when you got 1kb of uploaded file, you can parse it, and maybe send a redirection back to client, and handle that data. So a little tricky, but not impossible.

Upvotes: 1

Tamás Szabó
Tamás Szabó

Reputation: 348

Try to check this question, Maybe it has the answer for you.

Receiving only chunks of an uploaded file in PHP?

Upvotes: 1

Related Questions