How to upload large file in php
In php.ini default setting you can't upload large file more than 2MB..when you try you will get some error message like Warning: POST Content-Length of 281242912 bytes exceeds the limit of 7340032 bytes in Unknown on line 0Don't Worry if You want to Upload large file like 500MB,750MB 1GB More than 1GB File you need to configure your php.ini ..
just Follow the below step to Upload large file using php
How to upload large file in php |
Go to Your XAMPP Folder and Find out php.ini file and open it using CodeEditor or Notepad..
in this php.ini page we need to change the below values
memory_limit
upload_max_filesize
post_max_size
max_execution_time
Now Find out and change the below values
memory_limit
Your Desired size here such as 1000MB.
upload_max_filesize
Maximum allowed size for uploaded files.How big File you want to upload..such as 750M
post_max_size
Maximum size of POST data that PHP will accept.
max_execution_time
Maximum execution time of each script, in seconds
Your Complete Changes will be like below.. You can Increase The Value..
//Maximum amount of memory a script may consume (128MB) //http://php.net/memory-limit memory_limit=1000MB //Maximum allowed size for uploaded files. //http://php.net/upload-max-filesize upload_max_filesize=750M //Maximum execution time of each script, in seconds //http://php.net/max-execution-time //Note: This directive is hardcoded to 0 for the CLI SAPI max_execution_time=5000 //Maximum size of POST data that PHP will accept. //Its value may be 0 to disable the limit. It is ignored if POST data reading //is disabled through enable_post_data_reading. //http://php.net/post-max-size post_max_size=750M
Note: Restart XAMPP..
Now use The below PHP codes to test..index.php
<h2>Upload and Save image Using PHP MySQL</h2> <form method="POST" action="" enctype="multipart/form-data"> <input type="file" name="image"/> <input type="submit" name="submit" value="Upload"/> </form> <?php if(isset($_POST['submit'])){ //ini_set to Limiting File Size ini_set('post_max_size','524288000'); //Targeting Folder 'file' is folder name $target="file/"; $target=$target.basename($_FILES['image']['name']); $uploaded=move_uploaded_file($_FILES['image']['tmp_name'],$target); if($uploaded){ echo 'Your File Successfully Uploaded'; }else{ echo 'Failed to Upload'; } } ?>That's It friends how to upload large file in php..
please comments and share..
Thank You..
No comments:
Post a Comment
Thank You for Your Comment
Note: Only a member of this blog may post a comment.