[help] php的http上传文件问题 你只帖了表单,没有帖真正上传的源程序.PS:PHP的http上传容易出错的地方:1.服务器上传的文件夹的属性应为"777"(Linux);2.文件大小不能超过"MAX_FILE_SIZE"; 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这是php内容[我加上注释了] /* PHP 源程序。 自定函数: get_param(); 获得HTTP_POST_VARS 和 HTTP_GET_VARS & REQUEST_STR.. format_tags();==htmlspecialchar() error(); */ <? if(get_param('action')=="add_products"){ $s_item=format_tags(get_param("item")); $s_pnum=format_tags(get_param("p_num")); $s_pdes=format_tags(get_param("p_des")); $s_pfun=format_tags(get_param("p_fun")); if($s_pnum=="") error("ERROR:\\nProduct Number NULL!"); if($s_pdes=="") error("ERROR:\\nProduct Description NULL!"); if(!is_uploaded_file($_FILES['img']['tmp_name'][0])) error("ERROR:\\nUpload Product Small Photo Failed!"); if(!is_uploaded_file($_FILES['img']['tmp_name'][1])) error("ERROR:\\nUpload Product Large Photo Failed!"); $ext_name=substr($_FILES['img']['tmp_name'][0],-4,4); $save_imgs=time().random('6','1').strtolower($ext_name); if($ext_name!=".jpg" || $ext_name!=".gif" || $ext_name!=".JPG" || $ext_name!=".GIF" ) error("ERROR:\\nUpload File Type UNLL!\\nOnly support JPG/GIF"); Move_uploaded_file($_FILES['img']['tmp_name'][0], $pdt_dir.$save_imgs); $ext_name=substr($_FILES[img][tmp_name][1],-4,4); $save_imgb=time().random('6','1').strtolower($ext_name); if($ext_name!=".jpg" || $ext_name!=".gif" || $ext_name!=".JPG" || $ext_name!=".GIF" ) error("ERROR:\\nUpload File Type UNLL! Only support JPG/GIF"); Move_uploaded_file($_FILES[img][tmp_name][1], $pdt_dir.$save_imgb); $date="20".date('y-m-d h:i:s'); $db->query("Insert into products values ('','".get_session('s_user')."','$s_item','$s_pnum','$save_imgs','$save_imgb','$s_pdes','$s_pfun','$date')"); error("Add Product Successful,Please Continue..."); } ?> 真是的,一个问题等了3天! 还程序员大本营呢! Shit!Shit!Shit!Shit!Shit!Shit!Shit!Shit!Shit!Shit!Shit!Shit!Shit!Shit!Shit!Shit!Shit!Shit!Shit!Shit!Shit!Shit!Shit!Shit!Shit!Shit!Shit! php获取客户端MAC和IP地址 js代码嵌入失败 学习PHP应当注意些什么? checkbox血泪史 !DOCTYPE的问题请教 高手请进,有关变量提交!!! 请教,哪能找到用php写的网上聊天的源代码?在线等。 一个正则匹配无法匹配中文,怎样加上中文匹配? 能不能在一个页面将一个text的内容赋给一个变量?? ******请问怎样读写INI文件(基于linux,很急啊!)****** 怎么实现两个input值相加后显示在另外一个input中及数据库中数填充在input中? [help] php的http上传文件问题 两个设置分页的都出问题,想屎了...
/*
PHP 源程序。
自定函数:
get_param(); 获得HTTP_POST_VARS 和 HTTP_GET_VARS & REQUEST_STR..
format_tags();==htmlspecialchar()
error();
*/
<?
if(get_param('action')=="add_products"){ $s_item=format_tags(get_param("item"));
$s_pnum=format_tags(get_param("p_num"));
$s_pdes=format_tags(get_param("p_des"));
$s_pfun=format_tags(get_param("p_fun")); if($s_pnum=="") error("ERROR:\\nProduct Number NULL!");
if($s_pdes=="") error("ERROR:\\nProduct Description NULL!"); if(!is_uploaded_file($_FILES['img']['tmp_name'][0])) error("ERROR:\\nUpload Product Small Photo Failed!"); if(!is_uploaded_file($_FILES['img']['tmp_name'][1])) error("ERROR:\\nUpload Product Large Photo Failed!"); $ext_name=substr($_FILES['img']['tmp_name'][0],-4,4);
$save_imgs=time().random('6','1').strtolower($ext_name);
if($ext_name!=".jpg" || $ext_name!=".gif" || $ext_name!=".JPG" || $ext_name!=".GIF" ) error("ERROR:\\nUpload File Type UNLL!\\nOnly support JPG/GIF");
Move_uploaded_file($_FILES['img']['tmp_name'][0], $pdt_dir.$save_imgs); $ext_name=substr($_FILES[img][tmp_name][1],-4,4);
$save_imgb=time().random('6','1').strtolower($ext_name);
if($ext_name!=".jpg" || $ext_name!=".gif" || $ext_name!=".JPG" || $ext_name!=".GIF" ) error("ERROR:\\nUpload File Type UNLL! Only support JPG/GIF");
Move_uploaded_file($_FILES[img][tmp_name][1], $pdt_dir.$save_imgb); $date="20".date('y-m-d h:i:s');
$db->query("Insert into products values ('','".get_session('s_user')."','$s_item','$s_pnum','$save_imgs','$save_imgb','$s_pdes','$s_pfun','$date')");
error("Add Product Successful,Please Continue...");
}
?>