麻辣堂|资源主站|开发论坛|在线手册
首页 Apache Linux Java MySQL 注册帮助 
PHP项目开发组是PHP开发资源网于2007组年建成立的项目开发团队,目前核心开发成员有27人, 项目协作成员8名.下设7个开发组,主要承接大/中型网站项目开发任务。

    由于开发任务较多,人员比较紧张,现面向社会招聘全职或者兼职开发人员,不管你是在校大学生,还是全职开发人员,以及SOHO都可以联系本站,我们可以长期合作,并为您带来丰厚的报酬。
  您现在的位置:PHP开发资源网 > 麻辣堂 > 详细资料
待解决
upload文件合并后出现了问题
悬赏分:20 - 2007年08月18日

receiver.php3 [php] <? if($action1){ //如果文件上传,进行处理 ?> <? set_time_limit(60); // 以确保较大文件上传 $path1 = dirname($PATH_TRANSLATED)."/pic/"; //输出上传路径; //print $path1."
"; // assign our path in a form PHP for Windows understands for($i=1;$i<3;$i++) { $temp1="file".$i; $temp2="file".$i."_name"; $source=$$temp1; $source_name=$$temp2; // print $temp."=".$$temp."
"; //print $file1_name; //print $file2_name; //exit; //***************** //$source = $file1; //$source_name = $file1_name; //print $source."
"; //print $source_name; //exit; if(($source <> "none")&&($source <> "")) { // see if the file exists; non-existing file has name of "none" if($error1 <> 1) { // no need to copy a file if directory not write-enabled $dest = $path1.$source_name; // append file name to our path if(copy($source,$dest)){ // copy the file from the temp directory to the upload directory, and test for success echo "$source has been uploaded
\n"; $imagesize = getimagesize($dest); switch($imagesize[2]) { case 0: echo "
Image is a unknown
"; //unlink($dest); exit; case 1: echo "
Image is a GIF
"; echo "$dest has a width of $imagesize[0]
"; echo "$dest has a height of $imagesize[1]
"; $newname = $path1; $newname .=$i.time() . ".gif"; if(copy($dest,$newname)) { //echo "
GIF Rename Successful from $dest to $newname"; }else { //echo "
GIF Rename Unsuccessful"; } //unlink ($dest); break; case 2: echo "
Image is a JPG
"; echo "$dest has a width of $imagesize[0]
"; echo "$dest has a height of $imagesize[1]
"; $newname = $path1; $newname .=$i.time() . ".jpg"; if(copy($dest,$newname)) { //echo "
JPG Rename Successful from $dest to $newname"; }else { //echo "
JPG Rename Unsuccessful"; } //unlink ($dest); break; case 3: echo "
Image is a PNG
"; echo "$dest has a width of $imagesize[0]
"; echo "$dest has a height of $imagesize[1]
"; $newname = $path1; $newname .=time() . ".png"; if(copy($dest,$newname)) { //echo "
PNG Rename Successful from $dest to $newname"; }else { //echo "
PNG Rename Unsuccessful"; } //unlink ($dest); break; } }else { echo "Upload directory not write-enabled\n"; // you need to write-enable the upload directory $error1 = 1; // set flag } } { $link=mysql_connect("localhost","pro_f","123456"); mysql_select_db("pro"); $sql = "INSERT INTO productdata (productpic)VALUES('$newname')"; $result = mysql_query($sql) or die("MySQL Add Failed
"); echo "Add Mysql Record Success
"; } //unlink($source); // delete the file from the temp directory } ?> <? } //end for ?> <? } else { ?>

File 1:
File 2:

<? } ?> [/php] add.php [php] <? $dbname = "pro"; if (isset($_POST["Insert"])) { $link = mysql_connect("localhost", "pro_f", "123456") or die("Can't Connect MySQL!
"); mysql_select_db($dbname); $sql = "INSERT INTO productdata (serial, brandname, productname, model, "; $sql.= "productprice, productqty, productdate, productpic, producttype ) VALUES ('"; $sql.= $_POST["Serial"]."','".$_POST["Brandname"]."','"; $sql.= $_POST["Productname"]."','".$_POST["model"]."','"; $sql.= $_POST["Productprice"]."','"; $sql.= $_POST["Productqty"]."','".date('Ymd')."','"; $sql.= $_POST["Productpic"]."','".$_POST["Producttype"]."');"; $result = mysql_query($sql) or die("MySQL Delete Failed
"); echo "Add Record Success
"; } ?> <? $dbname = "pro"; $link = mysql_connect("localhost", "pro_f", "123456") or die("Can't Connect MySQL!
"); mysql_select_db($dbname); $sql2="SELECT brandname FROM stockdata "; $result=mysql_query($sql2); echo ""; ?>
Productpic:
Enter file name:

 

 

<? $dbname = "pro"; if (isset($_POST["Insert"])) { $link = mysql_connect("localhost", "pro_f", "123456") or die("Can't Connect MySQL!
"); mysql_select_db($dbname); $sql = "INSERT INTO productdata (serial, brandname, productname, model, "; $sql.= "productprice, productqty, productdate, productpic, producttype ) VALUES ('"; $sql.= $_POST["Serial"]."','".$_POST["Brandname"]."','"; $sql.= $_POST["Productname"]."','".$_POST["model"]."','"; $sql.= $_POST["Productprice"]."','"; $sql.= $_POST["Productqty"]."','".date('Ymd')."','"; $sql.= $_POST["Productpic"]."','".$_POST["Producttype"]."');"; $result = mysql_query($sql) or die("MySQL Delete Failed
"); echo "Add Record Success
"; } ?>
—Add Product Information—

     
Serial:
Brand:
<? $dbname = "pro"; $link = mysql_connect("localhost", "pro_f", "123456") or die("Can't Connect MySQL!
"); mysql_select_db($dbname); $sql2="SELECT brandname FROM stockdata "; $result=mysql_query($sql2); echo ""; ?>                  Add Brand
Model:
Name:
Price:
Qty:
Type:
<? $dbname = "pro"; $link = mysql_connect("localhost", "pro_f", "123456") or die("Can't Connect MySQL!
"); mysql_select_db($dbname); $sql2="SELECT producttype FROM stockdata"; $result=mysql_query($sql2); echo ""; mysql_close($link); ?>
Productpic:
<? if($action1){ //如果文件上传,进行处理 ?> 多文件上传

文件上传处理

<? set_time_limit(60); // 以确保较大文件上传 $path1 = dirname($PATH_TRANSLATED)."/pic/"; //输出上传路径; //print $path1."
"; // assign our path in a form PHP for Windows understands for($i=1;$i<3;$i++) { $temp1="file".$i; $temp2="file".$i."_name"; $source=$$temp1; $source_name=$$temp2; // print $temp."=".$$temp."
"; //print $file1_name; //print $file2_name; //exit; //***************** //$source = $file1; //$source_name = $file1_name; //print $source."
"; //print $source_name; //exit; if(($source <> "none")&&($source <> "")) { // see if the file exists; non-existing file has name of "none" if($error1 <> 1) { // no need to copy a file if directory not write-enabled $dest = $path1.$source_name; // append file name to our path if(copy($source,$dest)){ // copy the file from the temp directory to the upload directory, and test for success echo "$source has been uploaded
\n"; $imagesize = getimagesize($dest); switch($imagesize[2]) { case 0: echo "
Image is a unknown
"; //unlink($dest); exit; case 1: echo "
Image is a GIF
"; echo "$dest has a width of $imagesize[0]
"; echo "$dest has a height of $imagesize[1]
"; $newname = $path1; $newname .=$i.time() . ".gif"; if(copy($dest,$newname)) { //echo "
GIF Rename Successful from $dest to $newname"; }else { //echo "
GIF Rename Unsuccessful"; } //unlink ($dest); break; case 2: echo "
Image is a JPG
"; echo "$dest has a width of $imagesize[0]
"; echo "$dest has a height of $imagesize[1]
"; $newname = $path1; $newname .=$i.time() . ".jpg"; if(copy($dest,$newname)) { //echo "
JPG Rename Successful from $dest to $newname"; }else { //echo "
JPG Rename Unsuccessful"; } //unlink ($dest); break; case 3: echo "
Image is a PNG
"; echo "$dest has a width of $imagesize[0]
"; echo "$dest has a height of $imagesize[1]
"; $newname = $path1; $newname .=time() . ".png"; if(copy($dest,$newname)) { //echo "
PNG Rename Successful from $dest to $newname"; }else { //echo "
PNG Rename Unsuccessful"; } //unlink ($dest); break; } }else { echo "Upload directory not write-enabled\n"; // you need to write-enable the upload directory $error1 = 1; // set flag } } { $link=mysql_connect("localhost","pro_f","123456"); mysql_select_db("pro"); $sql = "INSERT INTO productdata (productpic)VALUES('$newname')"; $result = mysql_query($sql) or die("MySQL Add Failed
"); echo "Add Mysql Record Success
"; } //unlink($source); // delete the file from the temp directory } ?> <? } //end for ?>
Back

<? } else { ?> 多文件上传

File Upload

File 1:
File 2:

<? } ?>

     

 

 

[/php] 但既不能上传图片,mysql也不能增加 Warning: copy(C:\\Documents and Settings\\Administrator\\桌面\\1.GIF): failed to open stream: No such file or directory in /www/users/pro.hokays.com/admin/add.php on line 174 Upload directory not write-enabled Add Mysql Record Success

提问者:hoyin426   08-18 11:11
答复
路过。。。顺便帮顶:)
回答者:玉米づ冰冻可乐 - 瓦岗村民 8-22 09:10
我也来回答:
不管你有没有帮助我们,瓦岗寨8万村民将感谢你。。。。。

为防止灌水,您需要计算一道数学题: 答案:
57 + 97 = ? 请将计算结果填在上面

 
[]
©2007 PhpRes.COM