php上传字段保存到mysql
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> if($dsql->ExecuteNoneQuery($sql)) { //文件存储路径 $file_path="../upload/"; //664权限为文件属主和属组用户可读和写,其他用户只读 if(is_dir($file_path)!=TRUE) mkdir($file_path,0664); //定义允许上传的文件扩展 $ext_arr = array("gif", "jpg", "jpeg", "png", "bmp", "txt", "zip", "rar"); //获得文件扩展名 $temp_arr = explode(".", $_FILES["photo"]["name"]); $file_ext = array_pop($temp_arr); $file_ext = trim($file_ext); $file_ext = strtolower($file_ext); //获取上传文件的信息赋给变量 $upfile = $_FILES['photo']; $photo = $upfile; //以时间戳重命名文件 $new_name = time().".".$file_ext; //将文件移动到存储目录下 move_uploaded_file($_FILES["photo"]["tmp_name"],"$file_path" . $new_name); //向数据表写入文件存储信息以便管理 foreach($Items as $key=>$val) { $val['price'] = str_replace(",","",$val['price']); $dsql->ExecuteNoneQuery("INSERT INTO `#@__shops_products` (`aid`,`oid`,`userid`,`title`,`price`,`buynum`) VALUES ('$val[id]','$OrdersId','$userid','$val[title]','$val[price]','$val[buynum]');"); } $sql = "INSERT INTO `#@__shops_userinfo` (`userid`,`oid`,`consignee`,`address`,`zip`,`tel`,`email`,`qq`,`cphm`,`t1`,`t2`,`period`,`des`,`dabh`,`photo`,`scanning`) VALUES ('$userid','$OrdersId','$postname','$address','$zip','$tel','$email','$qq','$cphm','$t1','$t2','$period','$des','$dabh','$photo','$scanning'); "; $dsql->ExecuteNoneQuery($sql); } else { ShowMsg("更新订单时出现错误!".$dsql->GetError(),"-1"); exit(); } } else { $sql = "UPDATE `#@__shops_orders` SET `cartcount`='$CartCount',`price`='$priceCount',`ip`='$ip',`stime`='$stime',pid='$pid',paytype='$paytype',dprice='$dprice',priceCount='$lastpriceCount' WHERE oid='$OrdersId' AND userid='$userid' ;"; if($dsql->ExecuteNoneQuery($sql)) { $sql = "UPDATE `#@__shops_userinfo` SET `consignee`='$postname',`address`='$address',`zip`='$zip',`tel`='$tel',`email`='$email',`qq`='$qq',`cphm`='$cphm',`t1`='$t1',`t2`='$t2',`period`='$period',`des`='$des',`dabh`='$dabh',`photo`='$photo',`scanning`='$scanning' WHERE oid='$OrdersId';"; $dsql->ExecuteNoneQuery($sql); } else { echo $dsql->GetError(); exit; } unset($sql); }