|
今天,我没有使用ci框架中的类上传文件,使用的是php本身的上传函数,但是出现下面的错误
Message: move_uploaded_file(http://localhost/test2/upload/20111107101155eye.jpg) [function.move-uploaded-file]: failed to open stream: HTTP wrapper does not support writeable connections
Filename: controllers/upload.php
Line Number: 49
A PHP Error was encounteredSeverity: Warning
Message: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\xampp\tmp\php2822.tmp' to 'http://localhost/test2/upload/20111107101155eye.jpg'
Filename: controllers/upload.php
Line Number: 49
这是我的代码
function handle(){
$array_type=array(
"jpg",
"gif",
"png",
"jpeg",
"JPEG",
"JPG",
"GIF",
"PNG",
"rar"); //上传文件的类型
date_default_timezone_set("PRC");
$time=date("Ymdhms",time());
filepath为文件上传后保存的文件夹
$filepath=base_url().'upload/';
$filename为我的file的名字
$filename='userfile';
$name=$filepath.$time.$_FILES[$filename]['name'];
$type= substr(strrchr($_FILES[$filename]['name'], "."), 1);//获得上传的后缀
if(in_array($type, $array_type)){
//如果上传文件合法
if($_FILES[$filename]['size']>3000000){
$value=$time.$_FILES[$filename]['name'];
return $value; //上传文件不可以大于2M
}
else if(move_uploaded_file($_FILES[$filename]["tmp_name"], $name)){
$value=$time.$_FILES[$filename]['name'];
return $value;//上传成功
}
}else{
$value=$time.$_FILES[$filename]['name'];
return $value;//上传文件不合法
}
}
|
|