views:

508

answers:

6

Hi, i want to pass large variables to a PHP script on another server with http like: "example.com/get.php?data=this is quite alot data..."

I always get the server(apache) response: "Request-URI Too Large"

Any ideas hot to pass the big variables to that script?

+3  A: 

If data is too long for GET, what about using POST ?

(Considering the limitation on POST's size is generally arround 2 MB in PHP ; depends on configuration, and can be more.)

If you are using curl (that is if it's a PHP script on you server that does the request to another server ; else, you'll probably use a form in HTML), have a look at te documentation of curl_setopt : some options will definitly interest you ;-)

Pascal MARTIN
A: 

As have been said, you should really switch to POST.

The initial max size for POST is about 2mb, and can be configured by setting the upload_max_filesize and post_max_size in your php.ini file.

Silfverstrom
A: 

The best choice is $_POST. You can even use AJAX to add a "loading icon" if the variable is to big.

kuroir
A: 

Try using POST instead of GET? That is, something like this:

<form name=fooForm method=POST action=http://example.com/get.php&amp;gt; <input type="hidden" name=data value="this is quite a lot of data"> </form>

Either add in a submit button or trigger the submit using javascript somewhat like this:

<a href="javascript:document.fooForm.submit()">Submit</a>

You might also try passing the data via cookies, they can be up to 4KB in size.

A: 

Definitely use POST.

Incidentally, this link documents maximum url lengths:
http://www.boutell.com/newfaq/misc/urllength.html

  • Browsers: +- 2000
  • Apache: +- 4000
  • IIS: +- 16000
Joeri Sebrechts
A: 

If you have any sort of control over the source code of PHP script on the other server, it should be POST data and not GET. However, if you have a very valid/practical reasons to use GET instead of post. Then you need to make a trade off and sacrifice the ability to send very large data to keep use GET method.

There are upper limits to the lengths of the URL, as Joeri pointed out rightly and this limit may differ from browser to browser and server to server. It is also possible that different versions or same browser/server support different URL max lengths. Therefore there is a limit to the amount of data that you can send encoded in the URL over a GET request.

mirnazim