我一直卡在上传部分。我正在使用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内部服务器错误”状态码的基本含义是:“请检查日志以了解发生了什么”。你尝试过吗?猜测可能需要很长时间。 –