Skip to main content
deleted 1 character in body
Source Link
Giacomo1968
  • 56.1k
  • 23
  • 167
  • 214

Removing upload file size limitations

In order to configure a LAMP (Linux, Apache, MySQL, PHP) setup that allows a user to upload large files to their server the following has to be done:

Change the following variables in php.ini

  1. memory_limit = 1000M - Set memory limit to what is available on the system
  2. post_max_size = 4G - Ensure that this value is greater or equal to the upload_max_filesize value
  3. upload_max_filesize = 4G - Set this to whatever you want the maximum to be
  4. upload_tmp_dir: /mnt/raid10/Files/Temp - By default this is disabled which makes the temporary location be on the same disk as the OS is installed. In my case of running everything off of a Raspberry Pi, that makes it the SD card. To have less restriction, I set this to my network drive location instead.

After doing the above, the limitation in file upload size is the physical memory available to the device, whatever is set for memory_limit, and the file system limitations (4GB for a FAT file structure). In the case of my raspberry piRaspberry Pi 3, that was 1 GB1GB.

Bypassing the memory limit to upload a file bigger than the amount of memory available

The only way to go past the memory limit is to chunk the upload. Once chunking is enabled, what happens during an upload is the following:

  1. Upload initiated on webpage.
  2. Data from source file is streamed to the memory of webserver.
  3. Data is dumped from memory of webserver to temporary file location.
  4. Once the temporary file reaches the chunk size that was set, then that data is dumped into the final destination location file and the temp file is deleted.
  5. Repeat step 2 until file is completed.

How to use chunking

If you are using a download handler similar to this one (https://github.com/blueimp/jQuery-File-Upload/blob/master/server/php/UploadHandler.php) then there are many built in options available.

In my case, where the #fileupload is declared, I added a line for maxChunkSize:

$('#fileupload').fileupload({
    maxChunkSize: 10 * 1024 * 1024, // 10 MB <-----This is the line I added
    add: function (e, data) {
       blah blah blah
    }
    });
}
});

Whatever value is placed here will be the chunk size used. The size that you chose takes a little experimentation as one that is tiny will slow down the upload speed quite a bit, and one too large will result in the user of the site seeing no progress on their progress bar for quite some time. For me 10MB was a happy medium.

*Do note that the progress bar for the upload will move only when each chunk starts, so it becomes more choppy than a nice continuous progress bar but I am actually ok with this.

Removing upload file size limitations

In order to configure a LAMP (Linux, Apache, MySQL, PHP) setup that allows a user to upload large files to their server the following has to be done:

Change the following variables in php.ini

  1. memory_limit = 1000M - Set memory limit to what is available on the system
  2. post_max_size = 4G - Ensure that this value is greater or equal to the upload_max_filesize value
  3. upload_max_filesize = 4G - Set this to whatever you want the maximum to be
  4. upload_tmp_dir: /mnt/raid10/Files/Temp - By default this is disabled which makes the temporary location be on the same disk as the OS is installed. In my case of running everything off of a Raspberry Pi, that makes it the SD card. To have less restriction, I set this to my network drive location instead.

After doing the above, the limitation in file upload size is the physical memory available to the device, whatever is set for memory_limit, and the file system limitations (4GB for a FAT file structure). In the case of my raspberry pi 3, that was 1 GB.

Bypassing the memory limit to upload a file bigger than the amount of memory available

The only way to go past the memory limit is to chunk the upload. Once chunking is enabled, what happens during an upload is the following:

  1. Upload initiated on webpage.
  2. Data from source file is streamed to the memory of webserver.
  3. Data is dumped from memory of webserver to temporary file location.
  4. Once the temporary file reaches the chunk size that was set, then that data is dumped into the final destination location file and the temp file is deleted.
  5. Repeat step 2 until file is completed.

How to use chunking

If you are using a download handler similar to this one (https://github.com/blueimp/jQuery-File-Upload/blob/master/server/php/UploadHandler.php) then there are many built in options available.

In my case, where the #fileupload is declared, I added a line for maxChunkSize:

$('#fileupload').fileupload({
    maxChunkSize: 10 * 1024 * 1024, // 10 MB <-----This is the line I added
    add: function (e, data) {
       blah blah blah
    }
    });
}
});

Whatever value is placed here will be the chunk size used. The size that you chose takes a little experimentation as one that is tiny will slow down the upload speed quite a bit, and one too large will result in the user of the site seeing no progress on their progress bar for quite some time. For me 10MB was a happy medium.

*Do note that the progress bar for the upload will move only when each chunk starts, so it becomes more choppy than a nice continuous progress bar but I am actually ok with this.

Removing upload file size limitations

In order to configure a LAMP (Linux, Apache, MySQL, PHP) setup that allows a user to upload large files to their server the following has to be done:

Change the following variables in php.ini

  1. memory_limit = 1000M - Set memory limit to what is available on the system
  2. post_max_size = 4G - Ensure that this value is greater or equal to the upload_max_filesize value
  3. upload_max_filesize = 4G - Set this to whatever you want the maximum to be
  4. upload_tmp_dir: /mnt/raid10/Files/Temp - By default this is disabled which makes the temporary location be on the same disk as the OS is installed. In my case of running everything off of a Raspberry Pi, that makes it the SD card. To have less restriction, I set this to my network drive location instead.

After doing the above, the limitation in file upload size is the physical memory available to the device, whatever is set for memory_limit, and the file system limitations (4GB for a FAT file structure). In the case of my Raspberry Pi 3, that was 1GB.

Bypassing the memory limit to upload a file bigger than the amount of memory available

The only way to go past the memory limit is to chunk the upload. Once chunking is enabled, what happens during an upload is the following:

  1. Upload initiated on webpage.
  2. Data from source file is streamed to the memory of webserver.
  3. Data is dumped from memory of webserver to temporary file location.
  4. Once the temporary file reaches the chunk size that was set, then that data is dumped into the final destination location file and the temp file is deleted.
  5. Repeat step 2 until file is completed.

How to use chunking

If you are using a download handler similar to this one (https://github.com/blueimp/jQuery-File-Upload/blob/master/server/php/UploadHandler.php) then there are many built in options available.

In my case, where the #fileupload is declared, I added a line for maxChunkSize:

$('#fileupload').fileupload({
    maxChunkSize: 10 * 1024 * 1024, // 10 MB <-----This is the line I added
    add: function (e, data) {
       blah blah blah
    }
    });
}
});

Whatever value is placed here will be the chunk size used. The size that you chose takes a little experimentation as one that is tiny will slow down the upload speed quite a bit, and one too large will result in the user of the site seeing no progress on their progress bar for quite some time. For me 10MB was a happy medium.

*Do note that the progress bar for the upload will move only when each chunk starts, so it becomes more choppy than a nice continuous progress bar but I am actually ok with this.

Source Link
Eric F
  • 3.3k
  • 5
  • 26
  • 43

Removing upload file size limitations

In order to configure a LAMP (Linux, Apache, MySQL, PHP) setup that allows a user to upload large files to their server the following has to be done:

Change the following variables in php.ini

  1. memory_limit = 1000M - Set memory limit to what is available on the system
  2. post_max_size = 4G - Ensure that this value is greater or equal to the upload_max_filesize value
  3. upload_max_filesize = 4G - Set this to whatever you want the maximum to be
  4. upload_tmp_dir: /mnt/raid10/Files/Temp - By default this is disabled which makes the temporary location be on the same disk as the OS is installed. In my case of running everything off of a Raspberry Pi, that makes it the SD card. To have less restriction, I set this to my network drive location instead.

After doing the above, the limitation in file upload size is the physical memory available to the device, whatever is set for memory_limit, and the file system limitations (4GB for a FAT file structure). In the case of my raspberry pi 3, that was 1 GB.

Bypassing the memory limit to upload a file bigger than the amount of memory available

The only way to go past the memory limit is to chunk the upload. Once chunking is enabled, what happens during an upload is the following:

  1. Upload initiated on webpage.
  2. Data from source file is streamed to the memory of webserver.
  3. Data is dumped from memory of webserver to temporary file location.
  4. Once the temporary file reaches the chunk size that was set, then that data is dumped into the final destination location file and the temp file is deleted.
  5. Repeat step 2 until file is completed.

How to use chunking

If you are using a download handler similar to this one (https://github.com/blueimp/jQuery-File-Upload/blob/master/server/php/UploadHandler.php) then there are many built in options available.

In my case, where the #fileupload is declared, I added a line for maxChunkSize:

$('#fileupload').fileupload({
    maxChunkSize: 10 * 1024 * 1024, // 10 MB <-----This is the line I added
    add: function (e, data) {
       blah blah blah
    }
    });
}
});

Whatever value is placed here will be the chunk size used. The size that you chose takes a little experimentation as one that is tiny will slow down the upload speed quite a bit, and one too large will result in the user of the site seeing no progress on their progress bar for quite some time. For me 10MB was a happy medium.

*Do note that the progress bar for the upload will move only when each chunk starts, so it becomes more choppy than a nice continuous progress bar but I am actually ok with this.