LoginSignup
0
0

More than 3 years have passed since last update.

php ファイルのアップロード

Posted at
up.php
<!DOCTYPE html>
<html lang="ja">

<head>
  <meta charset="UTF-8">
  <title>img_upload</title>
</head>

<body>

  <?php
  var_dump($_FILES['file']);

  $filename =  './img/'.date('Y-m-d H:m:s') . '.jpg';

  if ($_FILES['file']) {
    move_uploaded_file($_FILES['file']['tmp_name'], $filename);

  }
  echo "<img src = '$filename'>"
  ?>
//enctypeは決まり文句
  <form action="up2.php" method="POST" enctype="multipart/form-data">
    <input type="file" name="file" accept="image/*">
    <input type="submit" value="ファイルをアップロードする">
  </form>




</body>

</html>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0