I am using uploadify plugin to upload files and update them in mysql database.
Smaller files are getting uploaded easily i.e. less then 1 mb files are getting uploaded and updated in the database.
But bigger files that is more than 4 mb or so are not getting uploaded.
Here is my code:
`
$j('#file_upload').uploadify({
auto : false,
'swf' : 'uploadify/uploadify.swf',
'uploader' : 'newuploadify.php',
// Put your options here
'queueSizeLimit' : 1,
'multi' : false,
'buttonText' : 'Add Photo',
'fileTypeDesc' : 'Image Files',
'fileTypeExts' : '*.gif; *.jpg; *.png; *.JPG',
'fileSizeLimit' : '10MB',
'onClearQueue' : function(queueItemCount) {
$j("#photocancelbtn").hide();
$j("#photouploadstartbtn").hide();
},
'onSelect' : function(file) {
$j("#photocancelbtn").show();
$j("#photouploadstartbtn").show();
},
'onUploadSuccess' : function(file, data, response) {
$j("#photocancelbtn").hide();
$j("#photouploadstartbtn").hide();
changeBtnText();
}
}); /* closing uploadify line*/
}); /* closing funciton line*/
});
`
The uploadify script:
`
<?php
/*
Uploadify
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
Released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
// Define a destination
require('newconnect.php');
$targetFolder = '/Mysite/uploadify/'; // Relative to the root
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];
// Validate the file type
$fileTypes = array('jpg','jpeg','gif','png'); // File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array($fileParts['extension'],$fileTypes)) {
$fp = fopen($tempFile, 'r');
$data = fread($fp, filesize($tempFile));
fclose($fp);
$query = $mysqli->prepare("Update help.posts set Photo=? where Pid=?");
$query->bind_param("si", $data,$pid);
$pid=3;
$query->execute();
} else {
echo 'Invalid file type.';
}
}
?>
`
Please let me know whats the error. I can upload smaller files but not larger files, although the upload limit i have set is 10 mb and also updated php.ini max-file-size to 10mb
Ok it got solved! The problem was in the file format. The script was not taking .JPG (in caps) but was taking .jpg