How to Import 1GB .sql file to WAMP/phpmyadmin
I suspect you will be able to import 1 GB file through phpmyadmin But you can try by increasing the following value in php.ini and restart the wamp.
post_max_size=1280M
upload_max_filesize=1280M
max_execution_time = 300 //increase time as per your server requirement.
You can also try below command from command prompt, your path may be different as per your MySQL installation.C:\wamp\bin\mysql\mysql5.5.24\bin\mysql.exe -u root -p db_name < C:\some_path\your_sql_file.sql
You should increase the max_allowed_packet
of mysql in my.ini
to avoid MySQL server gone away
error, something like thismax_allowed_packet = 100M
Set max file size PHP
You need to put the validation checks inside the for
loop that processes each file.
ALso, your limit on the number of images is wrong. You need to compare the number of files that were uploaded to $img_limit
, not compare $img_limit
to the same value you initialized it with.
I've taken the redirect and exit out of the loop, because that will redirect after uploading the first file. I've also taken prepare
and bind_param
out of the loop, since the same prepared statement can be used for each file.
$date_time = date('Y-m-d_H-i-s');
$img_limit = 10;
$maxsize = 3367463;
if(isset($_POST['submit'])) {
$errors = '';
$file_count = count($_FILES['files']['name']);
if ($file_count > $img_limit) {
$errors = 'Cannot upload more than 10 images';
}
if (!$errors) {
$stmt = $con->prepare("INSERT INTO images (image) VALUES (?)");
$stmt->bind_param('s', $file_path);
// Loop through each file
for( $i=0 ; $i < $file_count ; $i++ ) {
$file_name = $_FILES['files']['name'][$i];
$file_size = $_FILES['files']['size'][$i];
$file_tmp = $_FILES['files']['tmp_name'][$i];
$imageFileType = strtolower(pathinfo($file_name, PATHINFO_EXTENSION));
if ($file_size >= $maxsize) {
$errors = "Your file is too large";
} elseif ($imageFileType != "jpeg" && $imageFileType != "jpg" &&
$imageFileType != "png" && $imageFileType != "gif") {
$errors = "File type not allowed.";
}
//Make sure we have a file path
if (!$errors && $file_tmp != "") {
$picToUpload = $date_time . " -#- " . md5($file_name) . " -#- " . $_FILES['files']['name'][$i];
$uploadPicture = move_uploaded_file($file_tmp, "uploads/" . $picToUpload);
$file_path = "uploads/" . $picToUpload;
$stmt->execute();
}
}
}
}
if ($errors) {
$_SESSION['error'] = '<b><p style="color: #000; font-size: 30px; top: 34%;right: 50%;position: absolute;">
' . $errors . '</p></b>';
}
header('Location: index4.php');
exit();
The uploaded file exceeds the upload_max_filesize directive in php.ini error while uploading plugin
Seeing as though you've mentioned WAMP, I'm going to assume you can edit the php.ini file?
If you left click on the WAMP icon in the status bar, select the PHP menu and then click on the php.ini file in that menu. Just open it in Notepad is fine.
Then in Notepad, do a search (CTRL+F) for "upload_max_filesize", and then you can change the value that is set there.
I don't remember what the default is, but for mine, I have it set to "200M" (without the quotes). This means 200mb.
Save the file, close it, and then restart WAMP.
You should then be right to upload your plugin
Related Topics
Sending JavaScript Object to PHP via Ajax
Php, How to Get Current Date in Certain Format
PHP Date Function Seven Days Previous
Include Just Files in Scandir Array
PHP Local Server Invalid Request (Unexpected Eof)
How to Access Outer Local Variable in PHP
Why Use Output Buffering in PHP
Which PHP Mcrypt Cipher Is Safest
Find All Second Level Keys in Multi-Dimensional Array in PHP
How to Pass an Array into a PHP Soapclient Call
Codeigniter $This->Input->Post() Empty While $_Post Is Working Correctly
Convert Multidimensional Objects to Array
Cannot Unpack Array with String Keys
How to Get the Session Id in Laravel
Automatically Cancel Order After X Days If No Payment in Woocommerce