duanji1924 2012-09-11 01:58
浏览 65
已采纳

如何从Uploadify发送tmp_file到其他PHP页面

I am making a script to upload image files to one of many albums(dynamic). But i stuck at end, cannot retrive tmp_file(uploaded file) to move it to album. I am using uploadify v2.1.4

Here is my script. This is my javascript upload form.

     $(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>

On my uploadify.php when i echo $image_temp = $_POST['tmp_name']; its giving me no results but it gives me correct output for all other fields send via POST. Hence at the end i stuck & no image file to move toalbum!! Kindly provide guidance. I am using uploadify.php to insert data in database & moving image from temp to album folder.

  • 写回答

1条回答 默认 最新

  • dongtan7418 2012-09-11 04:26
    关注

    You're getting two scripts muddled up. "tmp_name" belongs to $_FILES in PHP, not the file object in uploadify.

    The script you have doesn't actually upload the file; your call to uploadify.php simply notifies that the file has been done.

    The actually file receiver is specified in a "script" parameter:

     $("#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, 
    

    .

    Then check $_FILES in 'upload/uploadify.php' for 'tmp_name' etc - this is where your file is.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line