Skip to content

Instantly share code, notes, and snippets.

@peace098beat
Created October 8, 2014 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peace098beat/9a6230fda71b0a62e846 to your computer and use it in GitHub Desktop.
Save peace098beat/9a6230fda71b0a62e846 to your computer and use it in GitHub Desktop.
save-upfile.php | フォルダ内の画像ファイル一覧を取得
<?php
/**********************************************************
/ ディレクトリ内の情報を取得する
/**********************************************************/
$array = scandir("./img/");
// mb_convert_variables("EUC-JP", "UTF-8", $array);
// mb_convert_variables("UTF-8", "UTF-8", $array);
// 画像ファイル以外を配列から削除;
$i = 0;
while($file_name = $array[$i]){
$path = "./img/".$file_name;
// echo "<p>".$path;
if(@getimagesize($path)){
$i ++;
}else{
array_splice($array, $i, 1);
}
}
/**********************************************************
/ サムネイル表示
/**********************************************************/
$j=0;
while($temp = $array[$j]) {
echo '<div class="section" id="mobile"><div class="w-container photo-con"><div class="w-row">';
if($a=$array[$j]){
echo '<div class="w-col w-col-3"><img class="photo-img" src=" '."./img/".$array[$j].' " alt=" '.$array[$j].' ">'.$array[$j++].'</div>
';
}
if($a=$array[$j]){
echo '<div class="w-col w-col-3"><img class="photo-img" src=" '."./img/".$array[$j].' " alt=" '.$array[$j].' ">'.$array[$j++].'</div>
';
}
if($a=$array[$j]){
echo '<div class="w-col w-col-3"><img class="photo-img" src=" '."./img/".$array[$j].' " alt=" '.$array[$j].' ">'.$array[$j++].'</div>
';
}
if($a=$array[$j]){
echo '<div class="w-col w-col-3"><img class="photo-img" src=" '."./img/".$array[$j].' " alt=" '.$array[$j].' ">'.$array[$j++].'</div>
';
}
// echo '<div class="w-col w-col-3"><img class="photo-img" src=" '."./img/".$array[$j].' " alt=" '.$array[$j].' ">'.$array[$j++].'</div>';
// echo '<div class="w-col w-col-3"><img class="photo-img" src=" '."./img/".$array[$j].' " alt=" '.$array[$j].' ">'.$array[$j++].'</div>';
// echo '<div class="w-col w-col-3"><img class="photo-img" src=" '."./img/".$array[$j].' " alt=" '.$array[$j].' ">'.$array[$j++].'</div>';
echo '</div></div></div>';
}
?>
<?php
/**********************************************************
/ アップロードファイルの保存
/**********************************************************/
if( $data = $_FILES["photo"] ){
move_uploaded_file( $data["tmp_name"], "./img/".date(U).$data["name"] );
// move_uploaded_file( $data["tmp_name"], "./img/".$data["name"] );
// echo("<img src='"."./img/".date(U).$data["name"]."' alt=''>");
}else{
// echo "nono";
}
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://orange.house.fififactory.com/www/index.php");
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment