我正在尝试在我的网站中实现 Uploadifive 插件,但我没有看到上传的文件。我没有看到任何错误。这是我的代码:
html
<div class="form-group" id="queue">
<label for="file">Add attachment</label>
{{ Form::file("file", ["id" => "file_upload", "multiple" => true]) }}
<a style="position: relative; top: 8px;" href="javascript:$('#file_upload').uploadifive('upload')">Upload Files</a>
</div>
js
<script type="text/javascript">
$(document).ready(function() {
$('#file_upload').uploadifive({
'auto' : true,
'queueID' : 'queue',
'uploadScript' : "/uploadfive/uploadifive.php",
'onUploadComplete' : function(file, data) { console.log(data); }
});;
});</script>
php
$uploadDir = "/public_html/myDomain.com/public/attachments/";
// Set the allowed file extensions
$fileTypes = array('jpg', 'jpeg', 'gif', 'png'); // Allowed file extensions
$verifyToken = md5('unique_salt' . $_POST['timestamp']);
$tempFile = $_FILES['Filedata']['tmp_name'];
$uploadDir = $_SERVER['DOCUMENT_ROOT'] . $uploadDir;
$targetFile = $uploadDir . $_FILES['Filedata']['name'];
// Validate the filetype
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array(strtolower($fileParts['extension']), $fileTypes)) {
// Save the file
move_uploaded_file($tempFile, $targetFile);
echo 1;
} else {
// The file type wasn't allowed
echo 'Invalid file type.';
}
在输出结果中我得到“1”,这表明没有错误,但我在附件文件夹中找不到上传的文件。
我也尝试使用public_path()
函数查找附件文件夹,但后来我得到了500 error
. 附件文件夹的权限也设置为777