0

I have a map that has about 50M, and I need to send it to my server in order to manipulate and return the process result. The problem is that my server only got 4MB so I'm trying to transform this data into a "file" and upload it.

I've already tried to change the Content-Type to "form-urlencoded" by doing something like this:

var obj = {};

obj.contentType = 'application/x-www-form-urlencoded';
obj.url = 'testsStamps.php';
obj.data = {'test':large_data};
obj.dataType = 'text';
obj.complete = function(jqXHR,textStatus){
    console.log(jqXHR,textStatus);
};
obj.beforeSend = function(xhr){
    xhr.overrideMimeType("application/x-www-form-urlencoded; charset=UTF-8");
    console.log(xhr);
};
$.ajax(obj).done(function(msg){$('#anchor').text(msg);});

But at server side there are no "$_FILES['test']" defined.

Besides that, the ".htaccess" has setted the "php_value post_max_size 100M" and " upload_max_filesize 100M". Plus, the "ini_set('memory_limit','250000M')".

bruno
  • 91
  • 2
  • 12
  • 4
    a server with 4meg of memory? Have the 80s come back that far? – Marc B Oct 31 '12 at 20:05
  • I think he means the PHP process is only allowed 4MB... – Ryan Griggs Oct 31 '12 at 20:07
  • Yep, is allowed only 4MB per user. – bruno Oct 31 '12 at 20:09
  • How will you prevent the server timing out during the upload? PHP also has a max_execution_time setting. Sounds like this would be a good place to use FTP. I would suggest trying a standard upload first (not ajax), just to see if the server accepts the file or times out. If the PHP process is only allowed 4MB of memory, i don't think it will even allow you to send such a large file... You would have to adjust the max memory settings. – Ryan Griggs Oct 31 '12 at 20:09
  • While I agree that this a PHP timeout could be an issue, if your server allows it, you might be able to use `ini_set('max_execution_time', 1000)` (possibly with a different value) to increase the execution time. – Joshua Dwire Oct 31 '12 at 20:12
  • You could try compressing the data before you send it. It might compress well and get you under the 4mb limit. See http://www.php.net/manual/en/function.gzcompress.php . – dmarra Oct 31 '12 at 20:14
  • I setted the max_execution_time to a suitable one. When I put a
    with a file input and select such size of archive, I'm able to send it normally. I didn't get to think about FTP. But it's possible to send a JSON or serialized data to a FTP Server straight from javascript?
    – bruno Oct 31 '12 at 20:17
  • user984444, I'll check it out. But I'm afraid that on the fly the situation come out of control. – bruno Oct 31 '12 at 20:23
  • 1
    duplicated [question](http://stackoverflow.com/questions/166221/how-can-i-upload-files-asynchronously-with-jquery) ? –  Oct 31 '12 at 20:57
  • You are not sending any headers or data that tells PHP that a file is arriving. Apart from that, how do you think you can manage to process a 50 MB file if your PHP is only allowed 4 MB? – Sven Oct 31 '12 at 21:27
  • Crisim: Nope. He actually wanted to upload a real file. I want to convert a string to file and send it to the server. In whatever way possible. – bruno Nov 01 '12 at 03:25
  • Sven: I tried some different headers, but without success. What is the right? About the post-manipulation: I thought that I could work line by line with it, then return the link of the file rebuilded for download on client side. I had the idea of split the string in lines or blocks and do the job by several POSTs. But the work time would be a lot slower, doesn't it? – bruno Nov 01 '12 at 03:33
  • I have a map that has about 50M - what does this mean? – James Nov 01 '12 at 21:17
  • James: In this case, it's a object that came from something like this: http://docs.jquery.com/Utilities/jQuery.map Here you can get further informations: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/map Look at the "Mapping" example. 50M means that when I POST it, it has about 50mb of informations. – bruno Nov 05 '12 at 15:19

0 Answers0