Error in uploading large file (php) - php

So I have a large file I need to upload via php (~1gb). After uploading the file I'm using php for further analysis.
My code works for smaller files. Is there a way to solve this issue? I changed php.ini to accommodate the upload of large file size but it still fails.
Update: I tried doing what people suggested in upload large files using php, apache and it still does not work.

Related

Uploading a chunk of a file

In my PHP web page, I allow my clients to upload a file. That file can be very large (1-2 GB). I already modified the php.ini in order to allow the users to upload big files.
Now, I want to know how to upload only 1 chunk of the file (the size of the chunk is selected by the user). For example, I have a 1 GB file, but I only want to upload the first 150 MB of that file (the file will still work even it has been chunked, but it will have less samples to work with).
How can I do that? If I do so, I will let the user not to have to wait much time uploading the 1 GB file, and the user will upload a 150 MB file instead (150/1000 MB).
I've found some ways to do it, like PLUPLOAD, but I prefer not to use JavaScript because I want to do all the process/job in my server and not in the client's side. Or with fread(), fopen() and fwrite(), but in this case, I can't use these commands without having uploaded the full file first.
P.D.: I can also use Python to chunk the file before uploading it, if it's necessary, but I think that I'll have the same problem as fread(), fopen(), etc...
Thank you.
If you're not willing to split up the file on the client before uploading it, you'll need to use some client-side code (on a supported browser) to perform partial uploads.
For an example, see https://github.com/blueimp/jQuery-File-Upload/wiki/Chunked-file-uploads

How can I get the IIS upload limit using PHP?

I want make a check against the IIS upload limit of the server my PHP script is running in the same manner as ini_get('upload_max_filesize') works for the PHP settings.
I'm thinking about parsing the web.config file to get the value of maxAllowedContentLength, but I was wondering if there is a standard way to ask the webserver directly.
There is one link telling a bit about other configuration setting you should read Which gets priority, maxRequestLength or maxAllowedContentLength? And i dont think there is other way as to read the ini file (php have simple ini file reader).
I could propose using some library that splits files like plupload - it can split your files to smaller pieces, upload each piece and then recombine it into one big file bypassing the server maximum upload file / body limits.

File upload in PHP not returning error code

I have a problem when attempting to upload really big files using PHP. I know this has been raised before and I have read many responses, but I have not found a definitive answer.
The basic code I use is posted here: http://design.wildsandwebdesign.co.uk/technical/uploading-files-2.php and I have used this with complete success for letting client upload image files, JPEG, GIF, png etc. The problem arose in allowing users to upload non-displayable files such as .psd files which can be very large.
In php.ini on both my local and remote servers upload_max_filesize and post_max_size are set to 128MB. The hidden field MAX_FILE_SIZE in the code has been set to various values during development. The problem is this: If the user selects a file bigger than the MAX_FILE_SIZE but smaller than 128MB,$_FILES['uploadfile']['error'] returns an error code of 2 as the PHP documentation says it will. If the file size exceeds 128MB then the upload handling fails altogether with bizarre results.
The “bizarre” results include irrelevant error messages such as “Undefined index: uploadbtn” this being the index of the submit button you have to click to get the error message(!) This happens with Firefox 26 and with Chrome. Bigger files can crash Firefox altogether which then displays the bug report dialog.
I don't want to upload files larger than 128MB, I just want to handle the situation where a user selects a very large file in some reasonable way. Does anyone know how to do this?
The production code is very much more complicated than the example above but I will happily provide it on request.
......

How to check whether a large file is uploaded correctly

I'm using Jquery file upload to upload files onto php server. I would like to modify the uploader such that I can check whether the uploaded file is the same as the local file.
My current idea is to use checksum to check whether the files are identical. However, I need to support large files (1GB). As I understand, we cannot load 1GB file using HTML5 File API for the hashing function.
The way Jquery file upload handles large file is to load part of the file and send it. So is there any way to do checksum when files are chopped into pieces? Or there are any other ways to check whether a file is correctly uploaded?
You should check for the file size, since HTTP connections won't mess up chunk order nor send wrong bytes. The real corruption will be in truncated files.

PHP - move_uploaded_file doesn't work for music/video

I'm working on a upload script and using move_uploaded_file() function. The problem is, that it only works for .txt, .jpg, .psd and some other file types I've tryed, but not for .mp3, .mov, .avi and maybe others.
There is nothing to the script, it's just the function. An interesting thing is, that it doesn't show any error msgs, it just doesn't upload the file.
Does anybody have some experience with this problem?
Thanks, Mike.
I don't think this is actually down to file type, more to file size.
Create a PHP script that runs a <? phpinfo(); ?> and look out for the upload_max_filesize setting. It could be that it is something like 8 MB, causing all larger file uploads to fail.
If that is the case, you can try changing the setting using ini_set("upload_max_filesize", "3200000000"); for example. In most cases, if on a shared hosting package, that will probably not work, though. You may have to contact your hosting provider then.
You should also make your script throw reliable error messages. The attempt to upload a file that is too big usually shows up as an error when uploading the file. Check the Error Messages Explained chapter in the manual for the respective error codes and their meanings.

Categories