1 / 11

PHP  ファイルアップロード

PHP  ファイルアップロード. ファイルアップロードの基本. html ファイルの フォーム から php プログラムへファイルデータを送る. html. php. ファイル選択用のフォーム. upload.html. <form name="form“ method="post“ action="upload.php“ enctype="multipart/form-data"> <input type=“file“ name=”●●“> <input type="submit“ name="button“ value=" 送信 "> </form>.

Download Presentation

PHP  ファイルアップロード

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. PHP ファイルアップロード

  2. ファイルアップロードの基本 htmlファイルのフォームから phpプログラムへファイルデータを送る html php

  3. ファイル選択用のフォーム upload.html <form name="form“ method="post“ action="upload.php“ enctype="multipart/form-data"> <input type=“file“ name=”●●“> <input type="submit“ name="button“ value="送信"> </form>

  4. File_upload phpプログラムの流れ upload.php ①htmlから送られてきたデータを変数に代入 ②ファイルサイズが0でないこと確認する (もし0ならエラーが発生しているのでexitする) ③アップロード先ディレクトリ名を指定 ④アップロードファイルのパス名を指定 ⑤一時ファイルを④に移動する

  5. File_upload(phpプログラム)① upload.php <?php //ファイル名を変数$name1に代入 $name1=$_FILES[“●●"]["name"]; //ファイルサイズを変数$size1に代入 $size1=$_FILES[" ●● "]["size"]; //ファイルの一時保存ファイル名を変数$tmp1に代入 $tmp1=$_FILES[" ●● "]["tmp_name"];

  6. uploadファイルデータの2次元配列 アップロードされるファイルのデータは2次元配列で管理される $_FILES[“●●"]["name"] $_FILES[“●●"][“size"] $_FILES[“●●"][“tmp_file"] $_FILES[“●●"][“type"]

  7. File_upload(phpプログラム)② upload.php ファイルサイズが0なら no upload fileと表示し終了し、0でないなら処理を続ける if($size1==0){ print"no upload file"; }else{  処理

  8. File_upload(phpプログラム)③④ upload.php アップロード先ディレクトリを指定 $updir="/home/fushimi/public_html/file/data/$dir/"; アップロードファイルのパス名を指定 $uppath1=$updir . basename($name1);

  9. File_upload(phpプログラム)⑤ upload.php 一時ファイルを④に移動する $rtn1=move_uploaded_file($tmp1,$uppath1); ファイルの移動が成功すれば succeedと表示し、失敗していれば、 Moving file is failed と表示し終了 if($rtn1===true){ print "succeeded <br>"; }else{ print "Moving file is failed"; }

  10. Upload_fileの移動 クライアント サーバ pre4306 /tmp/???? b08015\マイドキュメント\ /home/fushimi/public_html/file/data b08059\マイピクチャ\

  11. Upload_fileの移動 クライアント サーバ pre4306 /tmp/???? b08015\マイドキュメント\ /home/fushimi/public_html/file/data b08059\マイピクチャ\

More Related