-1

我的数组有什么问题,我收到错误消息“数组”,这并没有说明它有什么问题。我看不出它有什么问题,它没有将图片上传到预期的文件夹,只是希望有人能帮助我。

<?php

$s = "-";

 $sqlName=mysql_query("SELECT * FROM business WHERE email='$login_bus' LIMIT 1")or die   
 ("Sorry we have a mysql error!");

 $row=mysql_fetch_array($sqlName);$busID=$row["id"];$busName=$row["businessName"];   


 $upload_path = ''.$busName.'/productServiceImage/';

 $valid_formats = array("jpg", "png", "jpeg", "JPG", "PNG", "JPEG");
 if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST");
 {
 $name = $_FILES['pro_serImage']['name'];
  $size = $_FILES['pro_serImage']['size'];

 if(strlen($name))
 {
 list($txt, $ext) = explode(".", $name);
 if(in_array($ext, $valid_formats))
 {
 if($size<(1024*1024)) // Image size max 1 MB
{
$actual_image_name = time().$s.$busID.".".$ext;

$tmp = $_FILES['pro_serImage']['tmp_name'];
if(move_uploaded_file($tmp, $upload_path.$actual_image_name))
{
 list($width, $height) = getimagesize(''.$upload_path.$actual_image_name.'');

mysql_query("UPDATE product_service SET image='$actual_image_name',  
image_width='$width', image_height='$height' WHERE businessEmail='$login_bus' LIMIT  
1")or die ("Sorry we have a mysql error!");

echo "<img src='/".$upload_path.$actual_image_name."'>";
}
else
echo "failed! ".error_get_last()."";
}
else
echo "Image file size max 1 MB!"; 
}
else
echo "Invalid file format!"; 
}
else
echo "Please select image!";
exit;
}
?>
4

2 回答 2

0

更改此行

echo "failed! ".error_get_last()."";

print_r(error_get_last());
于 2013-09-19T13:39:08.163 回答
0

如果您回显一个数组,它将显示“数组”。如果是您的问题,我不会,但是您应该使用 print_r() 的 var_dump() 而不是 echo。这些将显示数组的内容。

于 2013-09-19T13:39:53.627 回答