Upload File Size Limit: Symfony Admin Generator Module - php

I have form created by the admin generator in the backend of a website. It allows the upload of a video to the site.
It works fine but strangely, the upload fails for files of 10mb or over. However, I have not set any file limits in my form.
Are there Symfony/PHP/Apache/web browser settings regarding this type of behaviour that I can look into?
Or is there a way I can inform Symfony that I'd like to permit larger files?

Even I haven't ever worked with Symfony I expect the problem due to limitations on your Web-Server.
If you have the possibility to edit or add your .htaccess file then the following line of code will probably help you:
php_value upload_max_filesize 100M
the 100M in example is for 100 Megabyte.

Also make sure that (at a minimum) you update post_max_size to match. See the PHP documentation, especially the sections on "Common Pitfalls" and "Error Messages Explained".

Related

Can't upload large file in Laravel (php.ini settings are correct in my opinion)

I have the following problem in Laravel.
I would like to upload a file through a form. But for some reason if the file is larger than around 2100 KB, the validation fails, and says that the file is 'required' and I did not provide it.
I've read numerous articles, that this can be because of php.ini settings. On my server they are the following:
upload_max_filesize 64M
post_max_size 64M
These values are copied from the output of phpinfo(), so they are in effect.
And despite this, the upload fails even for a 2 MB file. Do you have any ideas what I could check/set to solve this?
I am using laravel 5.2, and PHP 7.
Check which server software you are using. Nginx for instance has it's own limit (default set to 1MB I believe). Apache might have it too. Consult the respective manuals for those packages on how to configure them. Or if you're using shared hosting, contact support to see if they can increase the limit.
Though this isn't a really scalable solution. Next time you might want to upload a 100MB file, and you probably don't want to allow 100MB requests on your servers. A better approach would be to split the file in smaller chunks in the frontend, with JavaScript, and submit them as parts of the same upload, then recombine the parts on the server once the file is completely uploaded. Beware of additional checks you'll have to do here though.
You might want to incorporate the following into your own code:
<?php
//--- this tries to override the default of only 2M file uploads.
ini_set("upload_max_filesize","25M");
ini_set("max_execution_time",600); //--- 10 minutes
ini_set("post_max_size","35M");
ini_set("file_uploads","On");
?>
In my case, it was HDD space issue. not enough space to store the file.
Laravel should handle it with proper message, instead of indicating user didn't upload anything.
If you are not using any other package to upload files to check , then
then remember to restart apache .

Debugging techniques for a PHP script with many, many file uploads?

I have a PHP script which services a form that contains many, many file uploads. There's about 40 separate files being uploaded, although each one is less than 30 KB in size (so about a meg, total of actual data is being transfered).
I'm using CakePHP for this, if it somehow makes a difference.
The problem I'm having is that only 19 of the files are being uploaded (once they're uploaded I send out an email using GMail as an SMTP relay). I've checked the obvious things, such as listed here:
Can file uploads time out in PHP?
And I've got generous values for everything.
Could anyone suggest strategies to use for running down this problem and/or specific things to check?
I don't think it is a CakePHP issue. Apache and php have certain limits on number of files and max size of files that can be uploaded at a time. Also there will be max post size.
There are two ways to overcome this
You can override the settings in .htaccess file like
php_value upload_max_filesize 10M
php_value post_max_size 15M
php_value max_file_uploads 50
Change it in php.ini file and restart server.
So after much, much digging it looks like it was a problem with my SMTP setup. I couldn't tell you how or why, but the problem was that attempting to email a zillion emails (well, ~40) caused the PHP process to halt (no error messages, nothing). Running the exact same code under XDebug worked fine, and putting a quarter-second sleep() after each email appears to work.
(On a semi-related note: Is there a way to delete a StackOverflow question that you've asked? :) )

Error when uploading image to PHP scripted website

I recently purchased a PHP script for my website. The software is working very well except when I try to upload images or videos (built in function). After I upload an image using the website script, the result is "broken image" icon in place of the picture. When you try to click on the image, the resulting link is:
http ://www..com/thumbnail.php?pic=C:*Upload Source Directory* \07172364.largeThumb.b.jpg&w=100&sq=Y&b=Y
After doing some research, I found some articles that state the php.ini needs to dictate how the php script handles image uploads. Upon looking at my php.ini file, the only line is:
session.save_path = "/home/<directory>/public_html/tmp"
session.use_only_cookies = on
I cannot find any information on what lines of coding need to be in my php.ini file in order to handle file uploads.
My questions are:
1) Am I looking in the right direction for solving this problem?
2) Is there a standard script that should be included in my php.ini in order to handle file uploads.
Thank you.
Given this is video and not images, when you say both should be supported, perhaps it's a filesize issue. In that case you're in the right spot (php.ini) and looking to increase the upload size to a value greater than your intended video size:
upload_max_filesize = 10M
post_max_size = 20M
The solution to this issue was that my webhost did not have my account setup correctly to upload images. Once I contacted my webhost, the setting was corrected and my issue was resolved.

Increase file upload size but cannot locate/access php.ini

I'm testing a file uploading page etc that I'm working on. Chose a largish file at random and received:
Request Entity Too Large
The requested resource
/admin.php
does not allow request data with POST requests, or the amount of data provided in the request exceeds the capacity limit.
as an error message. Brief google led to changing values in php.ini but I can't locate or access it.
The site is hosted on a free site 000.webhosting.org - I'm guessing they have it restricted somehow. Is there a workaround?
Create an .htaccess document and put it in you document root directory. Inside, place:
php_value upload_max_filesize 10M
Source: http://www.cyberciti.biz/faq/linux-unix-apache-increase-php-upload-limit/
Honestly, I've never tried this, but it appears to be what you need.
Edit:
Here's something else I found, you can try: ini_set("upload_max_filesize", "xM"); where x is a number and the M signifies Megabytes. I'm not sure if it works with all versions, but it's listed as being editable on the php website (http://www.php.net/manual/en/ini.list.php).

Can't upload file

I've made an CMS for a customer. One of the things he can do is upload a PDF file. We've tested this thoroughly and haven't encountered any bugs. However, he can't seem to upload anything at all. The file is never uploaded. His browser just keeps loading.
My client uses Firefox (not sure which version but I thought that wouldn't matter) and the PDF files he attempts to upload are around 5MB, nothing extreme.
Is there any reason why a browser doesn't finish it's request when uploading a file? I don't think the files are corrupt.
I don't think the problem lies in my script... but still worth posting:
if(!empty($_FILES['pdf'])) {
$path = '../pdf/';
$filename = $_FILES['pdf']['name'];
if(!empty($assoc['pdf'])) {
$oldfile = $path.$assoc['pdf'];
if(file_exists($oldfile)) {
unset($oldfile);
}
}
$success = move_uploaded_file($_FILES['pdf']['tmp_name'], $path.$filename);
}
Edit: He has sent me the PDF he's trying to upload. Took about 10 seconds to upload... I'm providing him a link to do a speed test, lol.
You can have two problems i see, might not be your exact problems but could lead you to your answer.
#1. POST_MAX_SIZE or UPLOAD_MAX_FILESIZE is not big enough
There are two configs that php programmers often forget about and this is probably your most obvious problem. Your tests have been done but have they been done with large files?
Using an htaccess or a php.ini (depending on your server configuration) you can override the php settings for
upload_max_filesize
post_max_size
And give them 20M for example:
/*.HTACCESS*/
php_value upload_max_filesize 20M
php_value post_max_size 20M
/*PHP.INI*/
upload_max_filesize = 20M
post_max_size = 20M
You cannot use ini_set() because these variables are used BEFORE php starts processing and thus would become useless in the context.
#2. enctype is not multipart/form-data
Although very unprobable, you might have forgot to set your enctype property on your form to "multipart/form-data" and thus, nothing gets sent to the server at all. But i doubt this is your issue since you said you tested it extensively.
BUT, sometimes, we move things around and forget to test (it happens to me too) and i was sure something worked before and now it's not, so check it out just to make sure :)
Good luck
Have the client try uploading the file in a different browser than Firefox. If it works in others browsers, try deleting (or renaming/moving, for testing purposes) the file MimeTypes.rdf in the client's Firefox profile folder.
If the PDF upload works afterwards, you encountered a Firefox bug that was first reported in 2007 (basically the same here, reported in 2006). In a nutshell, any web site from which the user ever downloads a file has the potential to corrupt the MimeTypes.rdf file in regards to the extension of the downloaded file - maliciously or accidentally/unknowingly.
Things you can do:
Vote for the Firefox bug!
Quick fix to get it working for the client right now: Have the user(s) delete their MimeTypes.rdf file. Firefox will create a new, "fresh" one at the next start, but this will clear all MIME type / application associations that the user has created over time. Also, this will only help until the user downloads the next PDF file from some other web site that corrupts the MimeTypes.rdf file again.
Use the "user agent" header to determine if the file is uploaded from Firefox. If so and the MIME type doesn't match anything you wish to accept, double-check the file name's extension and accept the file anyway if the extension matches your accepted file type(s) (".pdf" in your case).

Categories