![]() |
|
首页 │ Apache │ Linux│ Java│ MySQL│ 注册│帮助 | |||
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
}
?>
"); 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 ""; ?>

