1
我使用uploadify插件上傳文件並在mysql數據庫中更新它們。較大的文件沒有上傳並反映使用uploadify
小文件上傳很容易,即少於1 MB的文件在數據庫中上傳和更新。 但是大於4 MB的大文件沒有上傳。
這裏是我的代碼: `
$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*/
});
`
的uploadify腳本:
`
<?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.';
}
}
?>
`
請樂我知道最新的錯誤。我可以上傳較小的文件,但不是較大的文件,雖然我設置的上傳限制爲10 MB,並且也將php.ini最大文件大小更新爲10MB。