answersLogoWhite

0


Best Answer

By default, the maximum upload size in PHP is 2MB. This is kept in the php.ini file. To allow for the upload of larger files you have 3 options.

  1. Change the php.ini file. You're going to go into your php.ini file and look for the lines:

    memory_limit = 8M

    post_max_size = 8M

    upload_max_filesize = 2M

    You want to change the upload_max_filesize. Make sure that you don't exceed the post_max_size (if you do, then change them both.) Also, it's a good idea to make sure that memory_limit is always larger than post_max_size. (This applies to all these solutions.)

    After making changes to php.ini, your webserver will need to be restarted.

  2. Assuming you can't get into php.ini, you're using Apache, and you're running PHP as a module, you can use an .htaccess file. That file should contain the following lines:

    php_flag file_uploads On

    php_value memory_limit 8M

    php_value post_max_size 8M

    php_value upload_max_filesize 2M

    You put the .htaccess file in the root web folder, and it will apply to all the folders beneath it. If you do this and the server gives you a HTTP code 500 "Internal Server Error" then you aren't running Apache as a module and you can't do it this way. If it doesn't so anything, it's possible that you don't have the permissions to overwrite the Apache config via .htaccess.

  3. Finally, if all else fails, you can attempt to add a php.ini file to the webroot. PHP should find this ini file and abide by it. You don't need to copy every setting (anything not here is still in the original.) So your file should look something like this:

    [PHP]

    ; Whether to allow HTTP file

    uploads. file_uploads = On

    ; Maximum amount of memory a script may consume (8MB)

    memory_limit = 8M

    ; Maximum size of POST data that PHP will accept.

    post_max_size = 8M

    ; Maximum allowed size for uploaded files.

    upload_max_filesize = 2M

    If that technique fails, then it's time to admit defeat and call your hosting provider or IT guys and ask, politely, that they fix this for you.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the maximum size of a file that can be uploaded using PHP and how can you change this?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Basic Math

How do you upload and resize an image with PHP?


Difference between fup copy and fup load?

Use the FUP COPY command to move data one record at a time. COPY allows you to copy part of a file, and to copy records to and from devices other than disks,including tape drives, printers, and terminals. COPY also allows you to change file types by copying a file of one type into a target file of a different type. Use the FUP LOAD command to move data into a structured file. Data is transferred one record at a time from the source file and moved one block at a time into the destination file. The LOAD command has these advantages: • Loading files does not affect alternate-key values.Because data is written a block at a time, • LOAD is faster than COPY.


How do you create a script to upload a file in PHP?

Hope your requirement is to upload a file to server . follow this code. $files=array(); $file=handleUpload($_FILES); function handleUpload($upload_file){ if(!$upload_file) return; $files=array(); $file->file_orig_name = $upload_file['name']; $file->file_size = $upload_file['size']; $path_parts = pathinfo($file->file_orig_name); $file->file_extension = strtolower($path_parts['extension']); $file->file_mime_type = $upload_file['type']; $file->file_tmp_name = $upload_file['tmp_name']; return $files; }


When should globals be used in PHP?

Problem with using global variables in php is that they lose the the assigned value in a different php file. They only keep the global variable value in the php file in which they are declared. Instead of globals try and use $_SESSION or $_COOKIE to keep value intact across different php files in a project


What is the PHP command used to take a file name and inserts the file's contents into the script?

you can use: include($filename); // will give a warning if the file is not found include_once($filename); // same, but only includes if the file isn't already included require($filename); // will stop the script if the file is not found require_once($filename); // same, but only includes if the file isn't already included

Related questions

What is the past tense of upload?

Uploaded, as in, "Your file has been uploaded"


If you moved a file of you to utorrent download folder could it be uploaded?

No. The only way a file can be uploaded is to have a torrent file on your computer that refers to the specific file in question.


How do you view your HTML coding in a website?

A html file can be opened by any browser direct from your computer. For it to be actually on the web it needs to be uploaded to a web server.A html file can be opened by any browser direct from your computer. For it to be actually on the web it needs to be uploaded to a web server.A html file can be opened by any browser direct from your computer. For it to be actually on the web it needs to be uploaded to a web server.A html file can be opened by any browser direct from your computer. For it to be actually on the web it needs to be uploaded to a web server.A html file can be opened by any browser direct from your computer. For it to be actually on the web it needs to be uploaded to a web server.A html file can be opened by any browser direct from your computer. For it to be actually on the web it needs to be uploaded to a web server.A html file can be opened by any browser direct from your computer. For it to be actually on the web it needs to be uploaded to a web server.A html file can be opened by any browser direct from your computer. For it to be actually on the web it needs to be uploaded to a web server.A html file can be opened by any browser direct from your computer. For it to be actually on the web it needs to be uploaded to a web server.A html file can be opened by any browser direct from your computer. For it to be actually on the web it needs to be uploaded to a web server.A html file can be opened by any browser direct from your computer. For it to be actually on the web it needs to be uploaded to a web server.


How do you change file permissions on Yummy FTP?

Select the file you want to change permissions for in the directory listing. Click on the Info icon in the toolbar, or select Get Info from the File menu. Change the permissions in the Info window. You can automatically set permissions when you upload a file. In the Preferences window select Server Options and tick the Set permissions of uploaded files box.


Does something uploaded in your computer remain?

Yes, until you delete the file.


What do ftp servers do?

The servers take the files that are uploaded and process/send them based on the user/login id and the setup on the server. That specific login id is configured to take the uploaded file and send it to the destination. The destination/receiver processes the data in the file.


What is a video file?

It is a file of a movie or a video clip taken from a camera, or uploaded from an old movie system. Then the video clips can be viewed on a computer.


What is the maximum file size for a place on roblox?

There is no maximum file size for a Roblox place. It depends on how large of a computer you have and how fast it is. the larger the computer, the bigger the file.


What is the maximum file size permitted by MS publisher 2007?

what is the maximum size of a file im ms publisher 2007


I uploaded a YouTube video directly from imovie 09 and on imovie it says it uploaded but it's not on YouTube?

Honestly, the direct upload from iMovie is not the best thing to do. It is better to export the video file and upload it directly.


What does seeders mean in µtorrent?

µtorrent is a very tiny Bit torrent client that enables a user to download a specific file (specifically using torrent system) using a P2P (peer to peer) sharing. When we download a torrent, we do not get the file from a huge CPU commonly called server. Instead, we get a file uploaded by a user who already have downloaded it earlier. Once the seeders are online, they can upload tiny bits of file and µtorrent will compile it to form the file. The many the seeders, the faster the torrent will download.


How do you get active transfers for halo reach?

an active transfer is a file that is currently being downloaded or being uploaded to your fileshare.