Last active
February 10, 2019 01:47
-
-
Save ugeugeHigh/6d3f1551f247877eef490ea629850544 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$file = $_FILES['my_img']; | |
$ext = substr($file['name'], -4); //ファイル名の後ろ4文字を取得。つまり拡張子を取り出す | |
if($ext == '.gif' || $ext == '.jpg' || $ext == '.png' ) { | |
$filePath = 'tmp/' . $file['name']; //ファイルの移動先。 | |
move_uploaded_file($file['tmp_name'], $filePath);//アップロード | |
print('<img src="'.$filePath.'" />');//アップロードした写真を表示する | |
}else { | |
print('error'); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment