SOLVED: uploads not working

Permalink 3 users found helpful
I recently set up a C5 website for a client, but had a lot of trouble with the uploader. I tried adding an .htaccess file to raise the filesize limits, but GoDaddy didn't allow the lines I wrote in. I added php5.ini and php.ini files to raise the limits, but even with exorbitantly high limits, it didn't work. I was getting frustrated. Nothing would upload. I thought it was a C5 issue.

You may be familiar with the message: "An unknown error occurred while uploading the file. Please check that file uploads are enabled, and that your file does not exceed the size of the post_max_size or upload_max_filesize variables."

It's a PHP5 issue. Here's what you need to know:

In your php5.ini file, you do need to make sure your filesize limits are high enough and that file_uploads is set to "on", but much more importantly, you need to ensure that upload_tmp_dir is set to "/tmp/". I don't know if it's a GoDaddy thing (probably, I've had many bad experiences with them) or a PHP5 thing, but I didn't know that it no longer has a default value. It usually does.

Anyway, that's it! It's the most trivial thing. It took hours of digging to find the answer buried in a forum about PHP. Hopefully I save some people a bit of trouble.

curtis07
 
shotrox replied on at Permalink Reply
shotrox
Hi Curtis

I just had a similar issue and could not solve it as I cannot find the php5.ini on my server. I am hosting with bluehost and everything usually works great, now I tried to upload one mp3f file and got that error message "An unknown error occurred while uploading the file. Please check that file uploads are enabled, and that your file does not exceed the size of the post_max_size or upload_max_filesize variables."

Since then the entire uploading part i the file manager is gone! It is so weird... maybe a bug in the newest concrete5?

Thanks for letting me know if you see a solution for this? Or how to create the php5.ini and what to put in it...

Thanks!

Alexander
curtis07 replied on at Permalink Reply
curtis07
Open a text editor and copy the following in:

file_uploads = On
upload_max_filesize = 32M
post_max_size = 32M
upload_tmp_dir = /tmp/


Then save the file as php5.ini and upload it to the root of your C5 site.
shotrox replied on at Permalink Reply
shotrox
Hi Curtis
thank you very much for this. I did it but it did not work...
The uploader is still missing in the file manager - a very weird thing that never happened to me - I have built countless concrete5 pages...
I tried to upload a file that was bigger than usual and got that error message - since then the whole upload part is just missing...
Can you help?

I created the php5.ini and uploaded it in the root of the installation where the htaccess file is as well - was that the right location?

Thanks

Alexander
wagdi replied on at Permalink Reply
wagdi
@Shotrox- There is a fix for the missing 'Upload file' buttons here- http://www.concrete5.org/community/forums/block_requests/upload-fil...
shotrox replied on at Permalink Reply
shotrox
this worked great! Thanks!!!
shotrox replied on at Permalink Reply
shotrox
is there an upper limit to the filesize? I would not mind to be able to upload stuff beyond 100MB...
curtis07 replied on at Permalink Reply
curtis07
file_uploads = On
upload_max_filesize = 32M
post_max_size = 32M
upload_tmp_dir = /tmp/


Instead of what I already posted, use the following in your php5.ini file:

file_uploads = On
upload_max_filesize = 100M
post_max_size = 100M
upload_tmp_dir = /tmp/
jamesfinn replied on at Permalink Reply
jamesfinn
Good answer here sir!

The code written above successfully overrides any server configuration. I have researched for an hour on how exactly to change the "Upload Max" and "Post Max" limits that appear in the "Upload Multiple" window of the Concrete5 "File Manager". I created a file containing only the first three lines written in your code and saved it to the root as "php.ini". I opened the "Upload Multiple" dialog box and the changes were immediately apparent.

Thanks for this!!
larryaltongarrett replied on at Permalink Reply
Applied this fix, and still having problems. My Concrete5 5.5.2 install is several layers down in a subdirectory (/home/coffeein/public_html/walkfellowship/conc), and I've tried using the php5.ini file at each of these layers, but it has neither updated my max file size info through the file manager interface, nor has it allowed me to upload a 1.5MB .mp3 file. I would prefer to not upload these files via ftp, as I would like to maintain consistency in the file naming structure in the future. Any ideas?
lemony replied on at Permalink Reply
This just worked for me as well. Thanks, curtis.
Albin replied on at Permalink Reply
Curtis,
I am struggling with the same issue. I am using a "single PHP file"

I have tried adding the following to my htaccess file:
# php settings
php_value post_max_size 200M
php_value upload_max_filesize 199M

but bluehost does not allow that and it gets commented out and it will be edited to look like this:
# php settings
# File modified on Wed Mar 14 15:00:29 2012 by server
# For security reasons, mod_php is not used on this server. Use a php.ini file for php directives
# php_value post_max_size 200M
# For security reasons, mod_php is not used on this server. Use a php.ini file for php directives
# php_value upload_max_filesize 199M

I have also went in through the bluehost control panel (under php config) and re-installed the master php file INSTALL PHP.INI MASTER FILE and made sure that "single php was used", then re-added the necessary settings for the desired limit/s. (and renamed to php.ini)

I also tried coping the php.ini and then pasting it to the same directory but with the name php5.ini but that did not work. (seeing I have specified single php, I did not think this would work, but am trying everything at this time.)

I am not sue what the deal is. Have you figured anything out?


Thanks
Albin
curtis07 replied on at Permalink Reply
curtis07
file_uploads = On
upload_max_filesize = 200M
post_max_size = 200M
upload_tmp_dir = /tmp/


Create a file named php5.ini and copy and paste the above code into it. Then save it. Then upload it. php_value won't work in an ini file. It probably doesn't work because you left php_value before each line.
1PLM replied on at Permalink Reply
I am facing the same issue and followed your suggestions but the Max file upload error is still showing up after the new php.ini created.
The mp3's I am uploading is just 4.65 MB!
Confused about the location of where php.ini is located. In the wwwroot, I just see php.info. I copied your php code and pasted in a blank text doc and saved them as php.ini, php4.ini, php5.ini, and None is allowing the change for the Max file upload error.
I tried each one, by uploading to my wwwroot folder 1st, then into the Concrete folder - but still get the error "Uploaded file is too large. The current value of Upload-max-file size is 2MB"
I even created a folder called interviews in the Files directory and cannot even see that in the Dashboard under FILE MANAGER.

HELP, what am I missing!
THANKS.
Below id the code in my php.ini file
<?php
phpinfo();
post_max_size = 80M
file_uploads = On
upload_max_filesize = 80M
max_execution_time = 60 ;
curtis07 replied on at Permalink Reply
curtis07
You need to copy exactly what I have written. You're missing the "upload_tmp_dir = /tmp/" entry, and that's what's most important. Copy exactly what I have said and put save it as php5.ini, then put that file in your Concrete5 directory, the same place where the index.php page is located. Also, you don't need the php tags or phpinfo(). The error is still showing up because you didn't actually apply my fix.
nviau replied on at Permalink Reply
We also had problems with file uploads, but in my case it was was caused by a rewrite rule in .htaccess that rewrotes all non-file URLs to end with a slash (code taken from HTML5 Boilerplate).

So the URL /tools/required/files/importers/single was rewriten as /tools/required/files/importers/single/ by Apache and the post data was lost. Removing the rewrite rule fixed the problem. I thought it might be helpful to share.
lintu666 replied on at Permalink Reply
Hi
I also use this code ,but it doesnot work in my websute.Its window server can you please help me . When i upload large file it will appear internal 500 error.
lintu666 replied on at Permalink Reply
this is the code for uplaoding video..

if($_FILES['video']['name'])
{

$allowedExtensions = array("avi", "wmv", "mpg", "mpeg", "mov", "rm", "ram", "swf", "flv", "mp4");
$extension1 = pathinfo($_FILES['video']['name']);
$extension1 = $extension1["extension"];
foreach($allowedExtensions as $key=>$ext1)
{
if(strcasecmp($ext1, $extension1) == 0)
{
$boolValidExt1 = true;
break;
}
}
if($boolValidExt1==true)
{
$rand=rand(0,10000);

$uploadedFileName1 = "video".$rand.".".$extension1;
if(file_exists("gallery/videos/".$rand.".".$extension1))
unlink("gallery/videos/".$rand.".".$extension1);


if(is_uploaded_file($_FILES['video']['tmp_name'])) {
copy($_FILES['video']['tmp_name'], "gallery/videos/".$uploadedFileName1);

}
}


please help me
ThomasJ replied on at Permalink Reply
ThomasJ
Howdy, All!

I had the same problem. Trying to upload a 107Meg video I got the same error. And like most, I figured that it was a limitation pre-set by Concrete5, but it's an error being thrown by PHP. I tried using the php5.ini in the root directory as specified in this thread without success, so I changed these parameters in the master php.ini and restarted Apache. Now I have a 107 Meg file uploaded to my website.

After doing this with success proving that it is a PHP error being thrown, I did some research to put together the total picture of what's required, and the following is what I found.

PHP only looks at configuragtion in the main php.ini file at startup. I feel that this is the best place for these changes. This will make your changes universal and will apply to all domains that you are hosting on the same server. Don't forget to restart Apache for your changes to take effect. If you are using IIS, my condolences. You have another battle to contend with.

If you want the perimeters specified to only affect one domain, you could use a .htaccess file in the domain sub-directory. However, 'file_uploads On' and 'upload_tmp_dir /tmp/' cannot be performed within the .htaccess file. They cannot be changed at runtime. This may not matter to you though. 'file_uploads' are turned on by default and php just won't use a temp directory for caching the upload. If you do use a .htaccess file to change the following paramiters, You need to add 'AllowOveride on' (without Quotes) to your Apache configuration file in the <Directory “/var/full/path/to/domain_sub-root”> section of your virtual domain. Apache by default has AllowOverride set to none turning all override access off and .htaccess will not work without 'AllowOverride set to all' for the domain.
From what I gather after researching this, what you need in the .htaccess file is:
php_value upload_max_filesize 200M
php_value post_max_size 200M

For the proper structure of a .htaccess file, you will have to find that for yourself. I don't do .htaccess, at least not yet.
ThomasJ replied on at Permalink Reply
ThomasJ
p.s.
I found that setting user_ini.filename to the file to be read in the requested document's directory will cause php to look for this file for local configuration. If it's not set, which is my case, it doesn't look for any file which seems to be the default. I tried setting this to .user.ini, which the documentation suggests without success. Then I tried setting it to php5.ini and it still didn't work for me. Since some php installations do read a local php.ini file while accessing a domain directory, there must be an enable switch for this function someware within php.ini that I haven't found yet. The reason I am obsessing over this problem is that I would like to be able to change paramaters per domain as needed.

My testing process is; I have upload_max_filesize set to 200M in the main php.ini file. I created a php5.ini file in the domain directory with upload_max_filesize set to 8M. With a browser, I ask forwww.www.domain_name.com/phpinfo.php... to look at any change that is specified by the php5.ini file. So far, phpinfo reports upload_max_filesize 200M. I believe that if it were reading the local ini file, it would be changed to 8M in the phpinfo display.

If anyone has any suggestions, I'd be glad to get them.

Tom S.
tsilbermann replied on at Permalink Reply
tsilbermann
Adding
php_value upload_max_filesize 40M
php_value post_max_size 40M

to the .htaccess file in the root of the c5 installation solved this for me
jfhencken replied on at Permalink Reply
jfhencken
You can go to
Dashboard » System & Settings » Environment Information
and check the values for:

post_max_size - 10M
upload_max_filesize - 10M

I have a site on JustHost.com (BlueHost.com) which runs PHP v5.4.19

First I placed the following lines in a php5.ini file and placed it in /public_html and that had no effect.

file_uploads = On
upload_max_filesize = 100M
post_max_size = 100M
upload_tmp_dir = /tmp/


Next I changed the file name from php5.ini to php.ini and everything worked fine. A recheck of the Environment Info then read:

post_max_size – 100M
upload_max_filesize - 100M
joshuas replied on at Permalink Reply
This info was very helpful but I tried everything listed and still had the same issue (2M upload / 8M post). Finally I found the system 'php.ini' file located at /etc/php5/apache2/php.ini (Ubuntu Server 12.10) and searched for upload_max_filesize and post_max_size and made the edits there. Fixed!

CAUTION:
Changing this file (system wide php.ini) will apply to all your websites on your server that use php.
blakeage replied on at Permalink Reply
blakeage
php.ini nor php5.ini worked for me.

Adding this to .htaccess did:

php_value max_execution_time 360
php_value upload_max_filesize 60M
php_value post_max_size 60M
php_value upload_tmp_dir /tmp/
T30 replied on at Permalink Reply
In my case this error was due to a rule i've added in .htaccess file.
The rule was for replacing double slash in urls ('//' to '/'):
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301]

I would know why this rule interfers with the file manager, and why the given error is so misleading, but the important is that after a morning of trouble I've found the way out!
dbaggs replied on at Permalink Reply
dbaggs
Thanks T30 - although not the exact same rule, I too had a rule for trailing slashes and this was causing my issue.

Thanks for bringing a different perspective to the issue.
ThyagoTC replied on at Permalink Reply
Thank you very much. I had the same type of rule and that's what broke mine.
boltn replied on at Permalink Reply
boltn
Blakeage Thats the one!! cheerz mate