我一直卡在上傳部分。我正在使用uploadify腳本。正常的文件上傳成功,但當我累了上傳一個文件的名稱,如'file's.jpg然後發生HTTP 500錯誤。 我uploadify腳本是:使用uploadify上傳文件時出現HTTP 500錯誤
<script type="text/javascript">
// <![CDATA[
$(document).ready(function() {
$('#attachment').uploadify({
'uploader' : '<?php echo base_url();?>web/uploadify/uploadify.swf',
'script' : '<?php echo base_url();?>web/uploadify/uploadify.php',
'cancelImg' : '<?php echo base_url();?>web/uploadify/cancel.png',
//'folder' : '../../uploads/project_files/',
'folder' : '/admin_panel_new/assets/plupload/uploads/',
'auto' : true,
'multi' : true,
'hideButton': false,
'buttonImg' : "<?php echo base_url()?>images/attachment_image.gif",
'width' : 132,
'height' : 25,
'removeCompleted' : false,
'onSelect' : function(file) {
$('#submitFeedback').val('Please wait while uploading...');
$('#submitFeedback').attr('disabled','disabled');
},
'onComplete' : function(event, ID, fileObj, response, data) {
if($('#fileList').val()!='')
$('#fileList').val($('#fileList').val()+','+response);
else
$('#fileList').val(response);
//alert($('#fileList').val());
$('#submitFeedback').removeAttr('disabled');
$('#submitFeedback').val('Post Feedback');
},
'onError' : function(event, queueID, fileObj, errorObj) { alert(errorObj.type + ' ' + errorObj.info); }
});
});
</script>
我已經嘗試了許多其他的解決方案,但沒有運氣。
我uploadify.php代碼:
<?php
$targetFolder = $_POST['targetFolder']; // Relative to the root
$unik =$_POST['timestamp'];
$verifyToken = md5('unique_salt' . $_POST['timestamp']);
if (!empty($_FILES) && $_POST['token'] == $verifyToken) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
$targetFile = rtrim($targetPath,'/') . '/'.$unik.'_'.$_FILES['Filedata']['name'];
// Validate the file type
$fileTypes = array('jpg','jpeg','gif','png','txt'); // File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array($fileParts['extension'],$fileTypes)) {
move_uploaded_file($tempFile,$targetFile);
//
echo $unik.'_'.$_FILES['Filedata']['name'];
} else {
echo 'Invalid file type. Upload Failed';
}
}
?>
上傳錯誤圖像看起來像這樣
如果有人解決方案,請幫助。謝謝。
可能文件大小? – Sal00m
不,實際上文件只是一個kb而不是一個更大的大小。 –
「500內部服務器錯誤」狀態碼的基本含義是:「請檢查日誌以瞭解發生了什麼」。你嘗試過嗎?猜測可能需要很長時間。 –