swfupload中有一段if(@move_uploaded_file($upload_file["tmp_name"],$upload_file["filename"])){
//下面插入一段把路径保存到数据库中的代码;
// Create a pretend file id, this might have come from a database.
//产生一个上传文件id,这可能来自数据库;我在下面试着输出信息
结果是空白
好像没有执行呢
//下面插入一段把路径保存到数据库中的代码;
// Create a pretend file id, this might have come from a database.
//产生一个上传文件id,这可能来自数据库;我在下面试着输出信息
结果是空白
好像没有执行呢
简单的上传过程哪有这么多问题!
// Work-around for setting up a session because Flash Player doesn't send the cookies
/* if (isset($_POST["PHPSESSID"])) {
session_id($_POST["PHPSESSID"]);
}
session_start(); if (!isset($_FILES["Filedata"]) || !is_uploaded_file($_FILES["Filedata"]["tmp_name"]) || $_FILES["Filedata"]["error"] != 0) {
echo "There was a problem with the upload";
exit(0);
} else {
echo "Flash requires that we output something or it won't fire the uploadSuccess event";
}
*/
$updir="./upload/";//上传目录
$dirtype="1";//目录保存方式1:年/月/日;2:年/月;默认:年
$renamed="1";//是否重命名1表示重命名0表示用原来的文件名
$overwrite="1";//是否覆盖1表示覆盖0表示不覆盖
if (isset($_FILES["Filedata"]) && is_uploaded_file($_FILES["Filedata"]["tmp_name"]) && $_FILES["Filedata"]["error"] == 0) {
//上传文件赋值给$upload_file
$upload_file=$_FILES["Filedata"];
//获取文件类型
$file_info=pathinfo($upload_file["name"]);
//获取文件扩展名
$file_ext=$file_info["extension"];
//设置路径方式
switch($dirtype){
case '1':
$m_dir=date(Y)."/".date(m)."/".date(d)."/";
break;
case '2':
$m_dir=date(Y)."/".date(m)."/";
break;
default:
$m_dir=date(Y)."/";
break;
}
//设置上传的路径
$upload_path=$updir.$m_dir;
//建立文件夹
create($upload_path);
//需要重命名的
if($renamed){
list($usec, $sec) = explode(" ",microtime());
$upload_file['name']=substr($usec,2).'.'.$file_ext;
unset($usec);
unset($sec);
}
//设置默认服务端文件名
$upload_file['filename']=$upload_path.$upload_file['name'];
//检查文件是否存在
if(file_exists($upload_file['filename'])){
if($overwrite){
@unlink($upload_file['filename']);
}else{
$j=0;
do{
$j++;
$temp_file=str_replace('.'.$file_ext,'('.$j.').'.$file_ext,$upload_file['filename']);
}while (file_exists($temp_file));
$upload_file['filename']=$temp_file;
unset($temp_file);
unset($j);
}
}按照效果来说程序在这就结束下,在下面输出测试语句的时候什么都不会输出
if(@move_uploaded_file($upload_file["tmp_name"],$upload_file["filename"])){
//下面插入一段把路径保存到数据库中的代码;
// Create a pretend file id, this might have come from a database.
//产生一个上传文件id,这可能来自数据库;
这里本来是做数据库存储的,但是没执行到这
//这里必需echo内容可以是文件id或许数据库中的id,不然程序会出现错误,没有内容传回到index.php表单中的hidFileID中
echo $upload_file["filename"];
}else{
echo '';
}
} else {
echo ' '; // I have to return something or SWFUpload won't fire uploadSuccess
}
//建立文件夹
function create($dir)
{
if (!is_dir($dir))
{
$temp = explode('/',$dir);
$cur_dir = '';
for($i=0;$i<count($temp);$i++)
{
$cur_dir .= $temp[$i].'/';
if (!is_dir($cur_dir))
{
@mkdir($cur_dir,0777);
@fopen("$cur_dir/index.htm","a");
}
}
}
}
?>