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 asp.textbox后台赋值前端不能显示什么原因
  • ¥15 宇视监控服务器无法登录
  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥15 DruidDataSource一直closing
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误