我使用的PHP在此基础上现场闪光灯/ AJAX文件上传 - http://blog.codeville.net/2008/11/24/jquery-ajax-uploader-plugin-with-progress-bar/问题与阿贾克斯上传
有一个在我收到的行为有点不一致。
其中一个结果是将进程挂起,看起来像100%。 (我可以取消并在页面上做其他事情,但我只是没有更进一步。)
另一个是我点击upload_success_handler但文件仍然没有上传到服务器。我甚至暂时将我的权限更改为777,以排除所有问题,但仍无法上传。
如果任何人有任何这种类型的事情的经验,我想问什么发送到ajax调用文件,它是如何发送(get/post)。另外,我需要在由ajax调用的文件上做什么,以及我必须返回什么?我是否只是通过回显文件名来“返回”文件名,或者我是否真的使用了“返回”命令,就像它是一个函数一样。所有它在博客上说的是
处理程序应该将上传的文件保存到磁盘,然后返回一个唯一的标记,例如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;
}
}
}
?>
任何人有任何见解?先进的谢谢你。 – 2012-02-20 20:30:22
我现在每次都得到相同的行为。它似乎可以成功上传页面,甚至在上传完成后,当我在萤火虫中查看页面时,它甚至会将文件的名称插入到隐藏的输入中。我甚至可以提交并将所有正确的数据插入到数据库中。但是,该文件不会移动到服务器。我打开了错误报告,并且权限已经打开。 – 2012-02-20 22:41:50