0
我正在使用uploadify上傳PHP 5.3.3和Apache 2.2.16服務器的文件。 *我使用的所有圖像文件都很小< 1M上傳文件壞了
有趣的是,對於某些圖像文件,uploadify工作正常並正確上傳圖像文件。然而對於其他人而言,僅上傳8字節是奇怪的。我不知道爲什麼上傳的文件不完整。
Uploadify以某種方式表示文件已成功上傳100%,我也使用onError函數。
如何找出問題的任何幫助將是非常有用的。
Uploadify代碼:
$('#change_thumb_file').uploadify({
'hideButton' : true,
'wmode' : 'transparent',
'folder' : VG.PROJECT_ROOT + '/static/apps/vialogues',
'uploader' : VG.SITE_STATIC_URL+'uploadify/scripts/uploadify.swf',
'script' : VG.APPS_STATIC_URL+"vialogues/php/uploadify.php",
'buttonText' : 'Select an image',
'cancelImg' : VG.SITE_STATIC_URL+'uploadify/cancel.png',
'auto' : true,
'sizeLimit' : 5242880,
'queueID' : 'fileQueue',
'scriptAccess': 'always',
'method' : 'POST',
'queueSizeLimit' : 1,
'width' : '100',
'height' : '30',
'fileDesc' : 'images',
'fileExt' : '*.jpg;*.jpeg;*.png;*.bmp;*.gif',
'wmode' : 'transparent',
'altContent' : '<div id="flash_notice">Flash player version 10.0.0 or above is required to upload a video. Please click the icon below to download Flash player.\
<br /><a href="https://www.adobe.com/go/getflashplayer">\
<img src="' + VG.SITE_STATIC_URL + 'uploadify/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33">\
</a>\
</div>',
'onComplete' : function (event, queueID, fileObj, response, data){
preview_uri = response.replace(VG.PROJECT_ROOT, '');
$.ajax({
url:VG.SITE_URL + 'vialogues/api/crop_thumbnail',
type:'PUT',
data: {'img': preview_uri},
success: function(data){
$('#thumb_preview').empty().append('<img src="'+preview_uri+'" />');
},
failure: function() {alert("There was an unexpected error. Please try again."); window.location.reload()},
});
$('#step_two').fadeIn();
},
'onError' : function(event, queueID, fileObj, errorObj) {
var errMsg = "There was an error uploading ... \n";
errMsg += "Error type: " + errorObj.type + "\n";
errMsg += "Error Info: " + errorObj.info + "\n";
alert(errMsg);
}
});
它執行文件上傳(uploadify.php)代碼:
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_REQUEST['folder'] . '/';
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
$fileTypes = str_replace('*.','',$_REQUEST['fileext']);
$fileTypes = str_replace(';','|',$fileTypes);
$typesArray = split('\|',$fileTypes);
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array($fileParts['extension'],$typesArray)) {
$result = move_uploaded_file($tempFile,$targetFile);
if ($result) {
echo str_replace($_SERVER['DOCUMENT_ROOT'],'',$targetFile);
}
else {
echo 'Upload Failed';
}
} else {
echo 'Invalid file type.';
}
}
請提供您的問題與一些代碼來檢查出來,以便我們可以幫助你。問候 – 2012-02-28 21:21:59
包括代碼...但我不認爲這個問題是與代碼。我感覺文件上傳正在破裂,我不知道我怎麼知道它在哪裏。 – user504879 2012-02-28 21:33:41
你的Apache錯誤日誌中有什麼?另外,在上傳過程中,請檢查'/ tmp'的內容(假設您的服務器正在運行Linux),並查看是否有一個PHP臨時文件隨着您的上傳發送而增長。 – Crontab 2012-02-28 21:38:22