形式
HTML
投稿日時
2019-09-23 05:52
公開期間
無期限
  1. <?PHP
  2. # to be like this for examlple
  3. GIF89;aGIF89;aGIF89;a<html>
  4. <head>
  5. <title>PHP Test</title>
  6. <form action="" method="post" enctype="multipart/form-data">
  7. <input type="file" name="fileToUpload" id="fileToUpload">
  8. <input type="submit" value="upload file" name="submit">
  9. </form>
  10. </head>
  11. <body>
  12. <?php echo '<p>FILE UPLOAD</p><br>';
  13. $tgt_dir = "uploads/";
  14. $tgt_file = $tgt_dir.basename($_FILES['fileToUpload']['name']);
  15. echo "<br>TARGET FILE= ".$tgt_file;
  16. //$filename = $_FILES['fileToUpload']['name'];
  17. echo "<br>FILE NAME FROM VARIABLE:- ".$_FILES["fileToUpload"]["name"];
  18. if(isset($_POST['submit']))
  19. {
  20. if(file_exists("uploads/".$_FILES["fileToUpload"]["name"]))
  21. { echo "<br>file exists, try with another name"; }
  22. else {
  23. echo "<br>STARTING UPLOAD PROCESS<br>";
  24. if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"],
  25. $tgt_file))
  26. { echo "<br>File UPLOADED:- ".$tgt_file; }
  27. else { echo "<br>ERROR WHILE UPLOADING FILE<br>"; }
  28. }
  29. }
  30. ?>
  31. </body>
  32. </html>
ダウンロード 印刷用表示

このコピペの URL

JavaScript での埋め込み

iframe での埋め込み

元のテキスト