ajax上传者的问题

时间:2012-02-20 16:53:57

标签: php flash jquery file-upload swfupload

我正在使用基于此网站的php上的flash / ajax文件上传 - http://blog.codeville.net/2008/11/24/jquery-ajax-uploader-plugin-with-progress-bar/

我的行为有点不一致。

一个结果就是让流程看起来像是100%。 (我可以取消并在页面上做其他事情,但我不会更进一步。)

另一个是我点击了upload_success_handler,但该文件仍未上传到服务器。我甚至暂时将我的权限更改为777来统治所有这些,但仍然没有上传。

如果有人对此类事情有任何经验,我想问一下发送到ajax调用文件的内容以及如何发送(获取/发布)。另外,我需要对ajax调用的文件做什么以及我必须返回什么?我只是通过回显它“返回”文件名,或者我实际上是否使用“return”命令就像它是一个函数一样。所有它在博客上说是以下是

  

处理程序应将上传的文件保存到磁盘,然后返回一个唯一的标记,例如GUID或文件名,以识别刚刚上传的文件。

目前我对该文件中的代码的含义是如此

<?php
ini_set('post_max_size', 510000000);
ini_set('upload_max_filesize', 500000000);
ini_set('max_input_time', 20);
ini_set('memory_limit', 520000000);

if (!empty($_FILES['file']['name'])) //checking if file upload box contains a value
{

    $saveDirectory = 'videos/';         //name of folder to upload to
    $tempName = $_FILES['file']['tmp_name'];    //getting the temp name on server
    $fileName1 = $_FILES['file']['name'];       //getting file name on users computer

    $test = array();
    $test = explode(".", $fileName1);
    if((count($test) > 2) || ($test[1] != "avi" && $test[1] != "AVI" && $test[1] != "flv" && $test[1] != "FLV" && $test[1] != "mov" && $test[1] != "MOV" && $test[1] != "mpeg" && $test[1] != "MPEG" && $test[1] != "mp4" && $test[1] != "MP4" && $test[1] != "wmv" && $test[1] != "WMV")){
        $err .= "Invalid file type.  Files must have only one period \".\" and be of type .avi .flv .mov .mpeg .mp4 or .wmv";
        echo $err;

    }else{

        $count = 1;
        do{
        $link = $saveDirectory . $count . $fileName1;
        $count++; 
        }while(is_file($link));
        if (move_uploaded_file($tempName, $link))   //Moves the temp file on server
        {                                           //to directory with real name


            echo $link;

        } 
        else 
        {
            $err .= "There was an error while uploading the file.";

            echo $err;
        }
    }
}
?>

1 个答案:

答案 0 :(得分:0)

我想出来了。事实证明,博客中的javascript将文件输入重命名为我给出的其他内容。一旦我相应地调整了我的代码,它就有效了。在我建议输出$ _FILES []变量之后,我想出来了。我的asyncupload.php脚本的输出被移植回javascript生成的一个隐藏输入中。

我想我会在这个问题上为其他人发布我的解决方案。