我正在努力與uploadify目前。我遵循了文檔,但對於我的生活,我無法將文件上傳到文件夾。Uploadify。上傳工作,但不保存到文件夾
我在OSX上使用MAMP。上傳時,我可以看到上傳欄,在Chrome控制檯上沒有錯誤。 tmp文件夾是777
的意見/ upload.php的
<!DOCTYPE html>
<html lang="en">
<head>
<link href="<?php echo base_url() ?>assets/uploadify/uploadify.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="<?php echo base_url() ?>assets/uploadify/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="<?php echo base_url() ?>assets/uploadify/jquery.uploadify.v2.1.4.min.js"></script>
<script type="text/javascript" src="<?php echo base_url() ?>assets/uploadify/swfobject.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#file_upload').uploadify({
'uploader' : '<?php echo base_url() ?>assets/uploadify/uploadify.swf',
'script' : '<?php echo base_url() ?>assets/uploadify/uploadify.php',
'cancelImg' : '<?php echo base_url() ?>assets/uploadify/cancel.png',
'auto' : true
});
});
</script>
</head>
<body>
<input id="file_upload" name="file_upload" type="file">
</body>
</html>
upload.php的
<?php
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = '/Applications/MAMP/htdocs/tmp';
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
move_uploaded_file($tempFile,$targetFile);
echo str_replace($_SERVER['DOCUMENT_ROOT'],'',$targetFile);
}
您可能需要添加一個'/'到$ targetPath –
像魅力一樣工作。謝謝Pekka。 – GV1
沒問題。我會將它作爲答案添加,然後 –