奶头挺立呻吟高潮av全片,成人试看120秒体验区,性欧美极品v,A片高潮抽搐揉捏奶头视频

php語言

php上傳圖片客戶端和服務器端實現方法

時間:2024-08-22 03:40:34 php語言 我要投稿
  • 相關推薦

php上傳圖片客戶端和服務器端實現方法

  文章主要介紹了php上傳圖片客戶端和服務器端實現方法,涉及php操作文件的技巧,涉及圖片后綴驗證、文件重命名等常用方法,具有一定參考借鑒價值,需要的朋友可以參考下。

php上傳圖片客戶端和服務器端實現方法

  本文實例講述了php上傳圖片客戶端和服務器端實現方法。分享給大家供大家參考。具體如下:

  前臺表單代碼

  ?

  1

  2

  3

  4

  <form name="form1" method="post" action="admin_upfile.php" enctype="multipart/form-data">

  <input type="file" name="pic">

  <input type="submit" name="Submit" value="開始上傳" class="button">

  </form>

  后端php代碼

  ?

  1

  2

  3

  4

  5

  6

  7

  8

  9

  10

  11

  12

  13

  14

  15

  16

  17

  18

  19

  20

  21

  22

  23

  24

  25

  26

  27

  28

  29

  30

  31

  32

  33

  34

  35

  36

  37

  38

  39

  40

  41

  42

  43

  <?php

  //這里上傳 $upsize判斷上傳文件的大小

  $uppath = "/attached/"; //文件上傳路徑

  //轉換根目錄的路徑

  if (strpos($uppath, "/") == 0)

  {

  $i = 0;

  $thpath = $_SERVER["SCRIPT_NAME"];

  $thpath = substr($thpath, 1, strlen($thpath));

  while (strripos($thpath, "/") !== false)

  {

  $thpath = substr($thpath, strpos($thpath, "/") + 1, strlen($thpath));

  $i = ++$i;

  }

  $pp = "";

  for ($j = 0; $j < $i; ++$j)

  {

  $pp .= "../";

  }

  $uppaths = $pp . substr($uppath, 1, strlen($thpath));

  }

  $filename = date("y-m-d");

  if (is_dir($uppaths . $filename) != TRUE)

  mkdir($uppaths . $filename, 0777);

  $f = $_FILES['pic'];

  if ($f["type"] != "image/gif" && $f["type"] != "image/pjpeg" && $f["type"] != "image/jpeg" && $f["type"] != "image/x-png")

  {

  echo "<script>alert('只能上傳圖片格式的文件');window.close()</script>";

  return false;

  }

  //獲得文件擴展名

  $temp_arr = explode(".", $f["name"]);

  $file_ext = array_pop($temp_arr);

  $file_ext = trim($file_ext);

  $file_ext = strtolower($file_ext);

  //新文件名

  $new_file_name = md5(date("YmdHis")) . '.' . $file_ext;

  echo $dest = $uppaths . $filename . "/" . date("ymdhis") . "_" .

  $new_file_name; //設置文件名為日期加上文件名避免重復 上傳目錄

  echo $dest1 = $uppath . $filename . "/" . date("ymdhis") . "_" .

  $new_file_name; //設置文件名為日期加上文件名避免重復

  $r = move_uploaded_file($f['tmp_name'], $dest);

  ?>

  希望本文所述對大家的php程序設計有所幫助。

【php上傳圖片客戶端和服務器端實現方法】相關文章:

php上傳與刪除圖片的簡單范例03-31

PHP實現大文件上傳源代碼11-23

php上傳圖片并打上透明水印的代碼03-31

php實現圖片縮放功能類03-31

PHP實現多線程的方法03-29

php頁面緩存實現方法11-27

PHP基于CURL進行POST數據上傳的方法03-30

php生成圓角圖片的方法技巧03-29

PHP實現獲取域名的方法小結06-08

主站蜘蛛池模板: 高碑店市| 赞皇县| 瓦房店市| 潼关县| 玉溪市| 资源县| 博白县| 南皮县| 广饶县| 宣威市| 滨州市| 澄迈县| 三都| 班戈县| 庐江县| 罗田县| 武隆县| 莒南县| 慈利县| 乌兰浩特市| 邮箱| 兴国县| 日土县| 朔州市| 朝阳区| 腾冲县| 祁阳县| 岑溪市| 连州市| 堆龙德庆县| 乌恰县| 焉耆| 肃宁县| 泸州市| 宝兴县| 东安县| 邓州市| 富裕县| 珲春市| 博野县| 三穗县|