Uploadifive プラグインを自分の Web サイトに実装しようとしていますが、アップロードされたファイルが表示されません。エラーはありません。これが私のコードです:
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