これは以前に回答されたことは知っていますが、他の投稿の解決策はうまくいきません。アップロードしようとすると、uploadify ボックスで HTTP エラー (404) が発生します。
これは私のアップロード関連のコードです: head:
<link rel="stylesheet" type="text/css" href="js/uploadify/uploadify.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/uploadify/jquery.uploadify-3.1.min.js"></script>
体:
<input type="file" name="file_upload" id="file_upload" />
document.ready:
$('#file_upload').uploadify({
'swf' : 'js/uploadify/uploadify.swf',
'uploader' : 'js/uploadify/uploadify.php' ,
'cancelImg' : 'js/uploadify/cancel.png',
'multi' : false,
'buttonText' : 'Add main picture'
});
uploadify.php:
<?php
/*
Uploadify
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
Released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
// Define a destination
$targetFolder = 'C:/xampp/htdocs/site/sites_images/'; // Relative to the root
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $targetFolder;
$targetFile = $targetFolder . $_FILES['Filedata']['name'];
// Validate the file type
$fileTypes = array('jpg','jpeg','gif','png'); // File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array($fileParts['extension'],$fileTypes)) {
move_uploaded_file($tempFile,$targetFile);
echo '1';
} else {
echo 'Invalid file type.';
}
}
私は何が欠けていますか?