国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Simple file upload to local file for PHP development (1)

In this section, we use PHP code to upload files to a local folder and display them on the current page.

According to the idea mentioned in the previous section, we first create a simple form for uploading files

<html>
<head>
  <meta charset="utf-8">
  <title>圖片上傳</title>
  <style type="text/css">
    <!--
    body
    {
      font-size: 16px;
    }
    input
    {
      background-color: #66CCFF;
      border: 1px inset #CCCCCC;
    }
    -->
  </style>
</head>
<body>
    <form enctype="multipart/form-data" method="post" name="upform">
      上傳文件:
      <input name="upfile" type="file">
      <input type="submit" value="上傳"><br>
      允許上傳的文件類型為:
    </form>
    <br>圖片預(yù)覽:<br>
    <img src=""/>
</body>
</html>

Note here:

<form> The enctype attribute of the tag specifies in What content type to use when submitting the form. Use "multipart/form-data" when your form requires binary data, such as file content.

An image preview <img> is created at the bottom of the page to display the uploaded file.

The PHP code can later display the file name, size, length and width of the file saved in the local folder.


Secondly, we need to make some restrictions on uploaded files:

Types of uploaded files: $uptypes

<?php
    $uptypes=array(
      'image/jpg',
      'image/jpeg',
      'image/png',
      'image/gif',
      'image/bmp',
    );  //限制上傳格式為:jpg, jpge, png, gif, bmp
?>

Alright Set the upload file size, upload file path, etc. Here we have added image watermark settings.

<?php
    $max_file_size=2000000;     //上傳文件大小限制, 單位BYTE
    
    $destination_folder="uploadimg/"; //上傳文件路徑,默認(rèn)本地路徑
    
    $watermark=1;      //是否附加水印(1為加水印,其他為不加水印);
    
    $watertype=1;      //水印類型(1為文字,2為圖片)
    
    $waterposition=1;     //水印位置(1為左下角,2為右下角,3為左上角,4為右上角,5為居中);
    
    $waterstring = "";  //水印字符串
    
    $waterimg="";    //水印圖片
    
    $imgpreview=1;      //是否生成預(yù)覽圖(1為生成,其他為不生成);
    
    $imgpreviewsize=1/2;    //縮略圖比例
?>


Continuing Learning
||
<html> <head> <meta charset="utf-8"> <title>圖片上傳</title> <style type="text/css"> <!-- body { font-size: 16px; } input { background-color: #66CCFF; border: 1px inset #CCCCCC; } --> </style> </head> <body> <form enctype="multipart/form-data" method="post" name="upform"> 上傳文件:<br><br> <input name="upfile" type="file"> <input type="submit" value="上傳"><br><br> 允許上傳的文件類型為: </form> <br>圖片預(yù)覽:<br> <img src=""/> </body> </html>
submitReset Code