Commit 75ff105f authored by Anthony.Suerte's avatar Anthony.Suerte

File Upload Tester

parent 14e476b6
<?php
if(@file_exists("imgdir")){
$files = array_diff(scandir("imgdir"), array('.', '..'));
foreach($files as $file){
echo "{$file}<br/>";
}
}
<!DOCTYPE html>
<html lang="lang">
<head>
<title>File Upload Tester</title>
</head>
<body>
<form action="process.php" method="POST" enctype="multipart/form-data">
<input type="file" accept="image/jpeg,image/png,image/jpg,image/gif,application/pdf"
id="img1" name="img1"/>
<br/>
<br/>
<input type="submit" value="Submit"/>
</form>
</body>
</html>
\ No newline at end of file
<?php
function loadImageAds() {
$path = "imgdir";
// 該当ディレクトリの確認
if(!file_exists($path))
mkdir($path, 0777);
else
chmod($path, 0777);
$saveName = basename($_FILES["img1"]["name"]);
print_r($_FILES);
if(move_uploaded_file($_FILES["img1"]["tmp_name"], "{$path}/{$saveName}")) {
chmod("{$path}/{$saveName}", 0777);
return true;
}
return false;
}
if(loadImageAds()){
echo "<br/><br/>File Uploaded!";
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment