Solved

PHP upload files of up to 50MB

Posted on 2010-09-23
23
734 Views
Last Modified: 2012-05-10
Hi

I have hosting on a shared windows server.

I want to be able to let my clients upload large (ish) files to my server for me to work on...

I am unable to access the php.ini file to change the max file size settings so I am looking for an alternative that will allow me to upload files in the region of 50MB...

Anyone know of a workaround for this problem? FREE solution would be good!

Thanks

CD
0
Comment
Question by:cycledude
  • 11
  • 6
  • 6
23 Comments
 
LVL 9

Accepted Solution

by:
crazedsanity earned 400 total points
ID: 33744155
It is a per-directory configuration, so you should be able to put it in a ".htaccess" file (assuming the server is running Apache), in the form:

php_value upload_max_filesize 50M

For more information, take a look at the PHP page about it, as you will probably also need to look at the directive for post_max_size.  

DIRECTIVES PAGE: http://us.php.net/manual/en/ini.core.php#ini.upload-max-filesize
CONFIG CHANGES: http://php.net/manual/en/configuration.changes.php

Let me know if you need more information.
0
 

Author Comment

by:cycledude
ID: 33744610
Hi crazedsanity
Thanks for the feedback...  How do I find out (without asking the host) if it is running apache?
Cheers
 
 
0
 
LVL 9

Expert Comment

by:crazedsanity
ID: 33744825
Create a PHP file and put "phpinfo()" in it.  That will output pretty much everything you need to know (and probably a lot more): it should have lots of references to "apache" or "apache2".
0
 

Author Comment

by:cycledude
ID: 33744899
Hi again
I already tried that and it doesn't mention apache...  oh dear!
 
0
 
LVL 9

Expert Comment

by:crazedsanity
ID: 33745223
From what I've found with PHP running on Windows without Apache, it seems there may be little choice.  The only way I could potentially help you any further would be to give me a link to the info page or save it & attach as a file.  Sorry.
0
 
LVL 3

Assisted Solution

by:Progressed
Progressed earned 100 total points
ID: 33745392
no worries... just use uploadify! its a flash uploader and its uploads a file on the fly!

Youll get a nice upload status with it!

www.uploadify.com
0
 

Author Comment

by:cycledude
ID: 33745790
@progressed
Thats a nice upload utlilty, however it crashes at the same point as a normal file upload, due to the server not allowing over xMB
@crazedinsanity
See attached phpinfo

test.php.htm
0
 
LVL 9

Expert Comment

by:crazedsanity
ID: 33746202
It looks like the server is setup to use FastCGI on IIS 6.0.  You can attempt to put your own php.ini file in your "wwwroot" directory to see if that will override the default, but it looks like the server won't allow it (the "wwwroot" folder isn't in the path).

There is some good information about your setup here: http://www.php.net/manual/en/install.windows.iis6.php
0
 
LVL 3

Expert Comment

by:Progressed
ID: 33752333
Dont change default settings of your php.ini! its not set by default for nothing!

make a new file or add the following line to your .htaccess file:

php_value memory_limit 60M

This wel set the uploadlimit of ONLY this website to 60M.
0
 
LVL 3

Expert Comment

by:Progressed
ID: 33752395
offcourse i ment:

php_value upload_max_filesize 60M
php_value max_execution_time 1000

while your at it... the executiontime must be longer then default... duhh!
0
 

Author Comment

by:cycledude
ID: 33754353
@progressed
I already tried adding a .htaccess file with the following
php_value upload_max_filesize 100M
php_value max_execution_time 800
php_value post_max_size 100M
php_value max_input_time 100
php_value memory_limit 120M
 
but it did not work...
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 3

Expert Comment

by:Progressed
ID: 33754380
well it should...
0
 
LVL 9

Expert Comment

by:crazedsanity
ID: 33754414
@Progressed: the ".htaccess" solution is only applicable when the server is Apache.  This server is running PHP in FastCGI form on IIS/6.0.

@cycledude: did you try copying the php.ini to your public (wwwroot) folder and setting the values there?  HINT: after changing values, make sure to reload the page with the phpinfo() in it, see what INI file/values are there.
0
 

Author Comment

by:cycledude
ID: 33754460
@crazedsanity
I don't know where to locat the php.info file, I have never seen it?
 
 
0
 

Author Comment

by:cycledude
ID: 33754466
sorry i mean php.ini
 
0
 

Author Comment

by:cycledude
ID: 33754685
I just asked my host the same question and the response was:
"Not on Windows hosting I'm afraid.

It's a global php.ini"

Doh!
 

 
 
0
 
LVL 9

Expert Comment

by:crazedsanity
ID: 33755062
Unfortunately, it seems that you may not have any options here.  The host has all the control here, so you may have to somehow get them to update your upload_max_filesize setting, which probably has to be done in your website's configuration.
0
 

Author Comment

by:cycledude
ID: 33767639
Hi... Thanks for all the help
I guess it a 'change host' situation... although I would be grieved to do so as they have have been great...
I could use something like this, which allows you to upload massive files without any server side configuration
http://www.aspupload.com/
Is there a php alternative to this?
I could use ASP, it would not be a problem....
0
 

Author Comment

by:cycledude
ID: 33767643
Oh yeah, if there was a 'free' alternative it would be great!
 
0
 
LVL 3

Expert Comment

by:Progressed
ID: 33767663
welllll... lookie here! did the fileuploading stop around 30Mb?

Heres why!

to the MediaWiki LocalSettings.php configuration file for each wiki. In this example the PHP limit is set at 50 Mb. Note that these settings will not override the maximum settings set above (since the core php.ini and apache2 php.ini files set the absolute maximum). This method sets maximums that are less than the absolute maximum.

 Note: IIS7 Users. By default, IIS7 on Windows 2008 allows only 30MB to be uploaded via a web application. Larger files will return a 404 error after the upload. If you have this problem, you can solve it by increasing the maximum file size by adding the following code to <system.webServer> in the web.config file:

<security>
  <requestFiltering>
    <requestLimits maxAllowedContentLength=”50000000¿ />
  </requestFiltering>
</security>
With the above maxAllowedContentLength, users can upload files that are 50,000,000 bytes (50 MB) in size. This setting will work immediately without restarting IIS services. The web.config file is located in the root directory of your web site.
0
 

Author Comment

by:cycledude
ID: 33768552
@progressed
Hi Mate, the server I am on is iis6 and I am using php, although asp could be used, indeed even asp.net ....
But what you are referring to I believe is related to iis7, which I don't have access to.
Thanks for looking though.
 
0
 

Author Closing Comment

by:cycledude
ID: 33776448
Hello fellas

Well it looks like I have come full circle on this, and it looks like I am not going to be able to achieve the upload of large files without buying a 3rd part com object.

Thanks for the advice, I have awarded points to both experts but 80% goes to crazedsanity as he offered most advice.

Thanks

CD
0
 
LVL 3

Expert Comment

by:Progressed
ID: 33776469
too bad... well glad to be of assistance anyway!

Danny
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now