How to Upload large .sql mb file in phpmyadmin - php

How can I upload 140mb file on my phpmyadmin on my local server I am using WAMP server. When I import the file my browser getting hang and nothing will happen, and I also tried increasing time limitation in my php.ini file.

Have you tried compression?
If it's a table or database you're importing, there's a compression option while dumping the file. You have to choose : Custom - display all possible options and choose a compression method which saves lots of time and space.

try compression or create a script

You can use source command to import large files but it s only possible through shell script or Putty
source DATABASE_FILENAME.SQL

In your .htaccess file, you would add this code:
php_value upload_max_filesize 80M
php_value post_max_size 80M
php_value max_execution_time 300
php_value max_input_time 300
Hope these two links can solve your problem
stackoverflow thread
second link

If compression and setting limit in php.ini didn't solved your problem.
Try uploading in chunks.
Split your .sql file into number of files and import each of them separately.

Related

Increasing the Upload Limit of my PHP script

I have a simple PHP script. Its used to upload users into the joomla tables. Basically it uploads users into joomla three main tables.
The PHP uploader sript works fine when the CSV is about 80MB to 100 MB.
It does not work or just nothing happens when the file size is 500MB or above.
How do i make the PHP script work to upload the CSV files of over 500 MB?
Do i actually change something in my PHP.ini settings or is there something else i could
add in the script itself.
Thanks in Advance.
in the .htcaccess file add the following:
php_value upload_max_filesize 500M
php_value post_max_size 500M
in php.ini add:
upload_max_filesize = 500M
post_max_size = 500M
You have to change the upload_max_filesize in php.ini
I had the same issue long time ago with rails and mysql,
You have to consider 3 things when you want to upload a file:
Max upload file in PHP
Be sure that MySQL will save a big file.
Your browser will lost connection after a while uploading a file to your database if it don't receive any answer from the server.
I think that You handled the first 2, but to handle the 3rd probably you will need a upload progress bar to keep the session active. Actually you need some AJAX to keep the server and the client "talking" meanwhile the file still uploading.

Large file uploads failing php

I've made a tiny site where my friends can upload songs and some tiny files that they want to but my problem is that files over 5mb fails, as in the browser shows "Connection reset" error.
The max file size set by my server is 2Mb, but i can upload 2.5-3Mb fine
Probably because i overwrote it with .htaccess
But however file uploads over 5Mb they just don't get uploaded at all, as i said earlier browser cannot reach server.
Would this be a server issue? Or an issue in my code? Will i need to change things in order for large uploads to happen?
Also max post size and max file size is set to 40mb in the .htaccess file
Here is the website
http://sharebay.webatu.com/
You can try uploading some files over 7mb, mp3/flac/aac/m4a/wav/
Add these to .htaccess as well (adjust 10M to size in MB that you want):
php_value upload_max_filesize 10M
php_value post_max_size 10M
This assumes you don't have access to php.ini (otherwise it would be better to put there) and that your host does not prohibit htaccess overrides on these values.
If you've already tried that then post more info about your environment. If you are on a shared server it's probably not something you can change too much.
How long the upload takes?
If you have slow upload line then it should take more time then max_execution_time and then apache halts your PHP script.
Change file upload size
You can change it an .htaccess file.
.htaccess files are stored in the same directory as your .php files are. They modify configuration for that folder and all sub-folders. You simply use them by creating an .htaccess file in the directory of your choice (or modify it if present).
The following should enable you to increase your upload limit (if the server provider allows PHP config changes via .htaccess).
php_value upload_max_filesize 70M
php_value post_max_size 80M
php_value memory_limit 90M
php_value max_execution_time 240
php_value max_input_time 240
you can change size according ur need

Uploading files over 20MB via PHP to mySQL (GoDaddy Unix)

I am trying to modify existing PHP code, mySQL database and server settings (php.ini and .htaccess) at GoDaddy to allow for uploads in excess of 20MB (new limit will be 30M). Currently, when I upload anything larger than 8MB, the PHP code apparently executes (I know this because there is an update query that shows the result of the upload), no errors are reported from PHP, mySQL or the server, but nothing is uploaded either.
I have set the following parameters in the php.ini file:
memory_limit = 100M
post_max_size = 30M
file_uploads = On
upload_max_filesize = 30M
max_execution_time = 0
max_input_time = 0
my .htaccess file says
LimitRequestBody 0
My PHP code works well for files under 8 MB but I am having trouble figuring out why anything over that is not happening at all. I checked the file upload location (I physically upload the file to the server's filesystem before I insert/update the data into mySQL) and the files over 8MB never make it. So my guess is that this is where it fails.
Anyone have an idea what I am missing?
Thanks in advance for any input.
M
EDIT:
OK - feel free to award me the dufus badge! I am working in php5. The friggin php.ini file (at least on this server - don't know if this is true of other servers) only works for versions below 5. For version 5 you have to use php5.ini.
As per the GoDaddy support document: http://help.godaddy.com/article/1475
On MySQL side, there is max_allowed_packet variable that limits size of single request, e.g the size of SQL query. You can set it to 50MB or so in your case.
Use a phpinfo file to check for definite what the limits are. Just make a file with the following contents and call it whatever you like (with php extension...):
<?php phpinfo(); ?>
According to this post (http://wordpress.org/support/topic/upload_max_filesize-increase-on-godaddy) you need to add another line to your .htaccess:
suPHP_ConfigPath php.ini

PHP: Having trouble uploading large files

I am doing a file upload using PHP, which works fine for a file of size 2.8MB on my localhost - but not my Mediatemple GS host. Files smaller than 2MB work fine, but anything larger seems to not work... I am not getting any error message but when the upload finishes, the file is not found in the uploads directory...
I googled around, and I added the following lines to the .htaccess file:
php_value memory_limit 120M
php_value max_execution_time 120
php_value upload_max_filesize 10G
php_value post_max_size 10G
I know some of the above values are a overkill, but even then, this does not seem to help... Anything else I might be missing?
The one you missed is max_input_time, and do check whether your edits are reflected in phpinfo();.
Check the phpinfo() and look for these four values - it's possible that the changes you think you're making haven't been applied, or that something else is overriding your changes. The values you've changed look correct to me.

how to dynamically change the max upload file limit in php?

I want to change the max upload file limit dynamically. means by not changing the php.ini file on server.
Whenever user had uploaded more then 2 mb then my upload limit should be change.
I want to do all this through php.
Thanks in advance.
The limits enforces by upload_max_filesize are enforced before the php script is run, so the setting cannot be changed dynamically with ini_set.
For more information on the file upload ini settings and where they can be changed, see:
- http://php.net/manual/en/ini.core.php#ini.sect.file-uploads
- http://php.net/manual/en/configuration.changes.modes.php
Assuming by "user" you mean a visitor to your site, there are really only two methods you can enforce such a limit without the file reaching its final destination:
1) Before the upload has occurred: On the client side. You could definitely do this using a java-based uploader. Whether you can get the filesize of the selected file using javascript, I don't know.
2) After the file is uploaded to the server, but before you move it to the final destination (before you run move_uploaded_file)
Try this:
ini_set('upload_max_filesize', your_value_here);
Make sure also that you have specified the correct acceptable settings for:
file_uploads
upload_max_filesize
max_input_time
memory_limit
max_execution_time
post_max_size
If you can't modify your php.ini, you might be able to do it with a .htaccess file:
php_value upload_max_filesize 50M
php_value post_max_size 50M

Categories