[php]uploadify 无法上传文件 初学

WBOY
Lepaskan: 2016-06-02 11:28:09
asal
1077 orang telah melayarinya

phpupload

本人初学uploadify上传,使用给的demo无法将文件上传到uploads文件夹内
请各位大神给予指导
index.php

<code><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>UploadiFive Test</title>
<script src="jquery.min.js" type="text/javascript"></script><script src="jquery.uploadify.min.js" type="text/javascript"></script><link rel="stylesheet" type="text/css" href="uploadify.css">
<style type="text/css">body {    font: 13px Arial, Helvetica, Sans-serif;}</style>    <h1>Uploadify Demo</h1>    <form>        <div id="queue"></div>        <input id="uploadify" name="uploadify" type="file" multiple>    </form>        <a href="javascript:%24('#uploadify').uploadify('upload')">upload</a>    <script type="text/javascript">        <?php $timestamp = time();?>        $(function() {            $('#uploadify').uploadify({                'formData'     : {                    'timestamp' : '<?php echo $timestamp;?>',                    'token'     : '<?php echo md5('unique_salt' . $timestamp);?>'                },                'swf'      : '/php_test/uploadify/uploadify.swf',                'uploader' : '/php_test/uploadify/uploadify.php',                'folder'   : '/php_test/uploadify/uploads'            });        });    </script> </code>
Salin selepas log masuk

uploadify.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 = '/uploads'; // Relative to the root

$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,'/') . '/' . $_FILES['Filedata']['name'];

<code>// 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.';}</code>
Salin selepas log masuk

}
?>

<code></code>
Salin selepas log masuk
Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan