上传图片文件用PHP处理

1.html文件

form表单注意。enctype属性

代码:


添加商品

  • 产品分类

  • 货架



查看数据:

   

    echo "
";

      print_r($_POST);

      echo "
"; echo "
";

      print_r($_FILES);

      echo "
"; exit;

测试如图:

上传图片文件用PHP处理_第1张图片

。php文件代码:

";

      // print_r($_POST);

      // echo "
"; // echo "
";

      // print_r($_FILES);

      // echo "
"; // exit; $name = $_POST['goodsname']; $price = $_POST['goodsprice']; $sort = $_POST['goodsort']; $shelf = $_POST['shelf']; $brand_id = $_POST['brand_id']; //图片上传 $src = $_FILES['img']['tmp_name']; $name = $_FILES['img']['name']; $ext = array_pop(explode('.', $name)); $dst = '../../public/uploads/'.time().mt_rand().'.'.$ext; if(move_uploaded_file($src, $dst)){ echo "upload success"; //图片缩放200*200 }else{ echo "upload error"; } ?>



你可能感兴趣的:(php,php,php图片文件上传,文件上传)