Home  >  Article  >  Backend Development  >  Use PHP to process image file uploads

Use PHP to process image file uploads

不言
不言Original
2018-06-02 16:24:523505browse

This article mainly introduces the use of PHP to process image file uploads. It has certain reference value. Now I share it with everyone. Friends in need can refer to

1.html file

Form form attention. enctype attribute

Code:


添加商品

  • 产品分类

  • 货架

View data:

    echo "
";

      print_r($_POST);

      echo "
"; echo "
";

      print_r($_FILES);

      echo "
"; exit;


The test is as shown:


. PHP file code:

";

      // 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"; } ?>

Related recommendations:

php method example of uploading image files in post mode

The above is the detailed content of Use PHP to process image file uploads. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Mysql and php linkNext article:Mysql and php link