站长专注于Linux,Apache,Mysql,php技术
承接wordpress模板定制,wordpress定制,网站定制开发,网站接口定制
EMAIL:godchi@sina.com
扣扣:366609877
手机:13852852148
本人目前就职单位:靖江市智迅软件有限公司 http://www.jjzxun.com
Popularity: 99%
站长专注于Linux,Apache,Mysql,php技术
承接wordpress模板定制,wordpress定制,网站定制开发,网站接口定制
EMAIL:godchi@sina.com
扣扣:366609877
手机:13852852148
本人目前就职单位:靖江市智迅软件有限公司 http://www.jjzxun.com
Popularity: 99%
还是不行啊,调不了啊,救命啊
很头痛啊,现在怎么调,都加不进去图片,超郁闷
我现在调好了插入了,但是更新就有问题啊,因为我之前插入数据时,图片时可加可不加,所以到修改时就没有了图案,这也是不是问题,我修改时不添加图片在更新也没有问题,但是如果修改内容是添加了图片后更新,再查看,图片还是没有,等于添加了图片也是没有图片
if(!empty($pic_data)){
$allow_type = array(‘image/jpeg’, ‘image/png’, ‘image/gif’, ‘image/pjpeg’,);
if(!in_array($pic_data['type'], $allow_type)) {
show_message(‘上传图片的类型不符合’, ‘./admin_showeditnews.php’);
}
if($pic_data['size'] > 1000000) {
show_message(‘上传的图片不能大于1MB’, ‘./admin_showeditnews.php’);
}
$appendix = strrchr($pic_data['name'], ‘.’);
$new_name = time().rand(0000, 9999).$appendix;
$save_url = ‘../attachments/’.date(‘Ymd’).’/';
if(!file_exists($save_url)) {
@mkdir($save_url);
}
if(!move_uploaded_file($pic_data['tmp_name'], $save_url.$new_name)) {
show_message(‘上传图片出错’, ‘./admin_showeditnews.php’);
}
$ppic = date(‘Ymd’).’/’.$new_name;
}
我这样写了个判断,同时我数据库这样写
$sql = “UPDATE `vsncg_news` SET `cid` = ‘$cid’, `title` = ‘$title’,”;
$sql .= (!empty($pic))?(“`npic`=’$ppic’,”):(”);
$sql .=”`content`=’$content’ WHERE `nid` = ‘$nid’”;
Jerry Chi
回复:
三月 1st, 2011 at 16:50
@ak47zhaoming,
用if(!$pic_data['size'])判断
如果图片文件大小为空,则使用不带图片的update语句
ak47zhaoming
回复:
三月 1st, 2011 at 16:58
@Jerry Chi,
是不是这样写啊,删除if(!empty($pic_data)){}这个判断
这样写SQL
if($pic_data['size']<0){
$sql="UNDATE `vsncg_news` SET `cid` = '$cid', `title` = '$title', `content`='$content' WHERE `nid` = '$nid'";
}else{
$sql="UNDATE `vsncg_news` SET `cid` = '$cid',`npic`='$ppic', `title` = '$title', `content`='$content' WHERE `nid` = '$nid'";
}
不行啊,我已经用print_r($pic_data['type']);都没东西输出,因为我没上传图案时,那个npic时空值,受到影响
链接已加。。
19条评论▼