2012-09-11 47 views
0

我正在製作腳本將圖像文件上傳到許多相冊(動態)之一。但我堅持結束,不能回顧tmp_file(上傳的文件)將其移動到相冊。我正在使用uploadify v2.1.4如何將tmp_file從Uploadify發送到其他PHP頁面

這是我的腳本。這是我的JavaScript上傳表單。

 $(document).ready(function(){ 
    //aleart('I am Ready!'); 
    $("#file_upload").uploadify({ 
     'uploader': 'upload/uploadify.swf', 
     'cancelImg': 'upload/cancel.png', 
     'auto': false, 
     'multi' :true, 
     'folder': 'uploads',**strong text** 
     'method' : 'post', 
     'queueSizeLimit' : 10, 
     'onQueueFull' : function(event, queueSizeLimit){ 
     alert(" You can upload " + queueSizeLimit + " files at once"); 
     return false; 
     }, 
     'onComplete': function(event, ID, fileObj, response, data) { 
      var album_id = $("#album_id option:selected").val(); 

     $.post("uploadify.php", { "name": fileObj.name, "tmp_name": fileObj.tmp_name, "path": fileObj.filePath, "size": fileObj.size, "album_id":album_id}, function(info){ 
      alert(info); 
      }); 
     } 
      }); 
      }); 

    </script> 
    </head> 

    <body> 
    <form method="post" action="" enctype="multipart/form-data"> 
    <input type="file" name="file_upload" id="file_upload" /> 
    <select id="album_id" name="album_id"> 
    <?php foreach ($albums as $album) { 
     echo '<option value="', $album['id'], '">', $album['name'],'</option>'; 
     } ?> 
    </select> 
    <a href="javascript:$('#file_upload').uploadifyUpload();">Upload File</a> 

    </form> 
    </body> 
    </html> 

在我uploadify.php當我回聲$image_temp = $_POST['tmp_name'];它讓我沒有結果,但它給了我正確的輸出對於所有其他領域通過POST發送。 因此,最後我卡住&沒有圖像文件移動到相冊!請提供指導。 我正在使用uploadify.php將數據插入數據庫&將圖像從臨時文件移動到專輯文件夾。

+0

在文檔中:http://www.uploadify.com/documentation/uploadify/implementing-uploadify/它要求提供一個Flash文件。我沒有看到你的例子。 –

回答

0

你得到兩個腳本混淆。 「tmp_name」屬於PHP中的$ _FILES,而不是uploadify中的文件對象。

您擁有的腳本實際上並沒有上傳文件;你對uploadify.php的調用只是通知文件已經完成。

的實際上是文件接收器的 「腳本」 參數中指定的:

$("#file_upload").uploadify({ 
    'uploader': 'upload/uploadify.swf', 
    'script': 'upload/uploadify.php',  //-- This bit is where the file gets uploaded to 
    'cancelImg': 'upload/cancel.png', 
    'auto': false, 
    'multi' :true, 

然後檢查'upload/uploadify.php'中的$ _FILES是否爲'tmp_name'等 - 這是您的文件的位置。

+0

嘿羅比......謝謝你讓我的腳本工作!......終於完成了! :) –

相關問題