php jquery 上传照片,上传后实时本页面预览

阅读更多

其实这个的主要部分并不是一个jquery,但是必须使用到
php程序部分,也只需要这个一个php程序就可以了
www.corange.cn亲测
header("Content-Type: text/html; charset=utf-8");
@header( "Cache-Control: no-cache, must-revalidate" );
@header( "Pragma: no-cache" );
@header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" );

if($_GET['act']=='upload'){
if($_POST['upload']=='upload'){

$updir ='upload/';
$uploadfile = $uploaddir . basename($_FILES['file']['name']);

$_FILES['file']['name']=strtolower($_FILES['file']['name']);
$tmp_filename=explode(".",$_FILES['file']['name']);
if($tmp_filename[(count($tmp_filename)-1)]=='jpg' || $tmp_filename[(count($tmp_filename)-1)]=='jpeg'){
$up_filename=$updir.md5($_FILES['file']['name'].$_FILES['file']['size']).".".$tmp_filename[(count($tmp_filename)-1)] ;

if(move_uploaded_file($_FILES['file']['tmp_name'],$up_filename)){
list($width, $height, $type, $attr) = getimagesize($up_filename);
$f1="";
echo '';
echo "";//修改时候直接替换掉原数据
echo "";
echo "";exit;
}else{
echo "";exit;
}
}else{
echo "";exit;
}


}
?>





exit;
}
?>




上传照片,上传后可以预览-www.corange.cn 网站开发代码


















Jquery请自行下载后测试



Jquery请自行下载后测试 原文地址:http://www.corange.cn/archives/2010/04/3603.html

你可能感兴趣的:(PHP,jQuery,UP,Cache,HTML)