PHP MySql - move_uploaded_file() issue


PHP MySql - move_uploaded_file() issue

我是php的新手,我有这个问题:

<>之前storeuploadeimage ($image) {if ($image['error'] == UPLOAD_ERR_OK){//ShopItem对象是否有ID?if (is_null($this->id)) trigger_error("ShopItem::storeUploadedImage():尝试为ShopItem对象上传没有id属性设置的图像",E_USER_ERROR);//删除本文之前的任何图像$ this -> deleteImages ();//获取并存储图像的文件扩展名$this->shopItemImg = strtolower(strrchr($image['name'], '。'));//存储图像$tempFilename = trim($image['tmp_name']);if (is_uploaded_file ($tempFilename)) {if (!(move_uploaded_file($tempFilename, $this->getImagePath()))) trigger_error("ShopItem::storeUploadedImage():无法移动上传的文件",E_USER_ERROR);if (!(chmod($this->getImagePath(), 0666)))) trigger_error("ShopItem::storeUploadedImage():无法设置上传文件的权限",E_USER_ERROR);}//获取图像的大小和类型$attrs = getimagesize ($this->getImagePath());$imageWidth = $attrs[0];$imageHeight = $attrs[1];$imageType = $attrs[2];//将图像加载到内存switch ($imageType) {案例IMAGETYPE_GIF:$imageResource = imagecreatefromgif ($this->getImagePath());打破;案例IMAGETYPE_JPEG:$imageResource = imagecreatefromjpeg ($this->getImagePath());打破;案例IMAGETYPE_PNG:$imageResource = imagecreatefromng ($this->getImagePath());打破;默认值:trigger_error ("ShopItem:: storeuploadeimage():未处理或未知的图像类型($imageType)", E_USER_ERROR);}//复制并调整图像大小以创建缩略图$ thumb_height = intval ($imageHeight/$imageWidth * SHOP_THUMB_WIDTH);$thumbResource = imagecreatetruecolor (SHOP_THUMB_WIDTH, $thumbHeight);imagecopyresample ($thumbResource, $imageResource, 0,0,0,0, SHOP_THUMB_WIDTH, $thumbHeight, $imageWidth, $imageHeight);//保存缩略图switch ($imageType) {案例IMAGETYPE_GIF:imagegif ($thumbResource, $this->getImagePath(SHOP_IMG_TYPE_THUMB));打破;案例IMAGETYPE_JPEG:imagejpeg ($thumbResource, $this->getImagePath(SHOP_IMG_TYPE_THUMB), SHOP_JPEG_QUALITY);打破;案例IMAGETYPE_PNG:imagepng ($thumbResource, $this->getImagePath(SHOP_IMG_TYPE_THUMB));打破;默认值:trigger_error ("ShopItem:: storeuploadeimage():未处理或未知的图像类型($imageType)", E_USER_ERROR);}$ this ->更新();}}之前

错误:

Warning: move_uploaded_file() [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: Filename cannot be empty in C:'wamp'www'risa'classes'shopItem.php on line 69
var_dump($_FILES):
array (size=1)
  'image' => 
    array (size=5)
      'name' => string '55.jpg' (length=6)
      'type' => string 'image/jpeg' (length=10)
      'tmp_name' => string 'C:'wamp'tmp'php9C26.tmp' (length=23)
      'error' => int 0
      'size' => int 175289

谢谢!

您使用move_uploaded_file( $tempFilename, $this->getImagePath(),但是move_uploaded_file的第二个参数必须是一个文件名move_uploaded_file( $tempFilename, $this->getImagePath().$tempFilenamemove_uploaded_file( $tempFilename, $this->getImagePath().$image['name']