0

The user is able to upload an image which will have a massive amount of image data. This image data is going to be stored temporarily on the browser in the textbox. Once the user submits the form to the PHP server using POST, I'm going to add the contents of that textbox to a blob in the database.

My question: Is there a maximum limit to the amount of characters an HTML textbox can take?

I read online somewhere that I won't be able to POST this textbox to the server (with PHP).

Jenz
  • 8,280
  • 7
  • 44
  • 77
Ihsan
  • 140
  • 1
  • 1
  • 12
  • 1
    image data in textbox, you sure this is the best way to go ? – Satya May 19 '14 at 06:59
  • it'd make more sense to just send the file via `multipart/form-data` form. but to answer your question, if you're using POST, I don't think input type text or a textarea has a limit. I can be wrong though. – kennypu May 19 '14 at 07:00
  • @Satya Yes, in my case, I need to store it temporarily in a textbox. At the initial stage, when the image upload I don't want to send it to the database, so I'm only reading the image data and showing it on the screen after the submit. – Ihsan May 19 '14 at 07:05
  • So you want it to upload twice? –  May 19 '14 at 07:06
  • @kennypu I'm using multipart/form-data for the initial upload where I store the image data on the page. See, the program is meant to show a background of the uploaded image temporarily until the user makes changes to it, etc.. – Ihsan May 19 '14 at 07:08
  • @jdo No, upload once, submit 2 forms at 2 different times. – Ihsan May 19 '14 at 07:16
  • If you upload your file, put the image data (base64?) value of it back to a textarea and upload this textbox again, you're uploading it twice, don't you? –  May 19 '14 at 07:21
  • @jdo Yes when you put it that way.. yes uploading twice... So does that mean that using `multipart/form-data` for both the forms should work, no issue? Regardless of the image data size. – Ihsan May 19 '14 at 07:26
  • Most likely you will be only limited by the max post size set in your php configuration. Nevertheless I would rethink the upload process. –  May 19 '14 at 07:33
  • @jdo, I don't know if it can be called upload twice.. First time yeah, second time, simply posting the image data to the server. – Ihsan May 19 '14 at 07:34
  • Then clarify what you mean with image data. If you base64_encode a file, the resulting string will be at least as big in size as the original file was, most likely bigger. If you upload an 1MB image, the base64 string will be also at least 1MB (or even bigger). –  May 19 '14 at 07:39

2 Answers2

2

There are limits on client computer (limits of virtual memory) and there can be and usually is a limit on server-side of how many bytes can be received. POST limit size on Apache can be viewed and changed like answered in this question.

Community
  • 1
  • 1
Rytis Alekna
  • 1,387
  • 7
  • 17
1

The preferred way of sending file is using multipart/form-data and convert it to blob there in server before storing in DB.

As of i know, we can store any amount of data in the input type text. There is no limit on the browser side. With POST, there is no technical limit in the browser, but usually one on the server side - see e.g. Apache's LimitRequestBody, PHP's post_max_size and so on.

from specs:

MAXLENGTH
The maximum number of characters that will be accepted as input. This can be greater that specified by SIZE , in which case the field will scroll appropriately. The default is unlimited.
mohamedrias
  • 18,326
  • 2
  • 38
  • 47