= 12) { echo "10MB以上のファイルは取り扱いが出来ません"; exit; } //mimeチェック ↓以下の配列に存在するマイムのみ許可 $cfg['ALLOW_MIME'] = array('image/jpeg', 'image/png', 'image/gif'); $mime = mime_content_type($file_tmp_name); if (!in_array($mime, $cfg['ALLOW_MIME'])) { exit; }; move_uploaded_file($file_tmp_name, $datfile); //$datfile="work/".$directory_path."/".$file_name; //$datfile = file_get_contents($datfile); //$datfile = mb_convert_encoding($datfile, "utf8", "sjis"); //-------------------------- $file = $datfile; $width = 1000; $height = 1000; list($width_orig, $height_orig) = getimagesize($file); $ratio_orig = $width_orig / $height_orig; if ($width / $height > $ratio_orig) { $width = $height * $ratio_orig; } else { $height = $width / $ratio_orig; } $file_type = mime_content_type($file); switch ($file_type) { case 'image/jpeg': $img = imagecreatefromjpeg($file); break; case 'image/png': $img = imagecreatefrompng($file); break; case 'image/gif': $img = imagecreatefromgif($file); break; default: break; } //-------------------------// $imgarray = array( array("size" => "1", "comp" => "85", "fnam" => "l"), array("size" => "1.5", "comp" => "85", "fnam" => "m"), array("size" => "2", "comp" => "85", "fnam" => "s") ); //-------------------------------------------------------------// foreach ($imgarray as $k => $v) { $fnam = $v['fnam']; $comp = $v['comp']; $size = $v['size']; //サイズ //-------------------------// $width = ceil($width / $size); $height = ceil($height / $size); //-------------------------// $new_img = imagecreatetruecolor($width, $height); //-------------------------// imagecopyresampled($new_img, $img, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); imagewebp($new_img, $directory_path . '/' . $fnam . 'img.webp', $comp); //-------------------------// } //-------------------------------------------------------------// imagedestroy($img); imagedestroy($new_img); //--------------------------- $sid=session_id(); //$newfilenamel = "imgl" . date('Ymd_His') . ".webp"; //-------------------------- $newfilenamel = "limg_{$sid}" . ".webp"; $newfilenamem = "mimg_{$sid}" . ".webp"; $newfilenames = "simg_{$sid}" . ".webp"; $newdir = "img/"; if (!file_exists($newdir)) { mkdir($newdir, 0777); } $fpathl= $newdir . '/' . $newfilenamel; $fpathm= $newdir . '/' . $newfilenamem; $fpaths= $newdir . '/' . $newfilenames; copy($directory_path . '/limg.webp',$fpathl); copy($directory_path . '/mimg.webp',$fpathm); copy($directory_path . '/simg.webp',$fpaths); //--------------------------- $base64datal = base64_encode(file_get_contents($fpathl)); $base64datam = base64_encode(file_get_contents($fpathm)); $base64datas = base64_encode(file_get_contents($fpaths)); $base64datal_size= round( strlen($base64datal)/1024,0); $base64datam_size= round( strlen($base64datam)/1024,0); $base64datas_size= round( strlen($base64datas)/1024,0); //----------------// $headword="data:image/webp;base64,"; //----------------// //---------------------------------------------------------//------ //アップロードして登録直後にファイル削除 $directory_path = "work/" . session_id(); $fileName = $directory_path . "/" . "*"; foreach (glob($fileName) as $val) { unlink($val); } //アップロードして登録直後にそのフォルダ削除 $directory_path = "work/" . session_id(); $fileName = $directory_path; foreach (glob($fileName) as $val) { rmdir($val); } //ついでにファイルがあれば削除 $directory_path = "work/"; $fileName = $directory_path . "/" . "*"; foreach (glob($fileName) as $val) { unlink($val); } //---------------------------------------------------------//------ //---------------------------------------------------------//------ //アップロードして登録直後にファイル削除 $directory_path = "img/" . session_id(); $fileName = $directory_path . "/" . "*"; foreach (glob($fileName) as $val) { unlink($val); } //アップロードして登録直後にそのフォルダ削除 $directory_path = "img/" . session_id(); $fileName = $directory_path; foreach (glob($fileName) as $val) { rmdir($val); } //ついでにファイルがあれば削除 $directory_path = "img/"; $fileName = $directory_path . "/" . "*"; foreach (glob($fileName) as $val) { unlink($val); } //---------------------------------------------------------//------ } } } //------------------------------------------------------------// $width="100px"; $height="25px"; $msg.=<< @charset "UTF-8"; input[type=file]:focus { outline: 0; } .box_base64 { margin: 20px; } .file-upload_area { margin-bottom: 5px; position: relative; } .file-upload_area .file-upload_input { margin-left: 20px; } .file-upload_area .file-upload_input::before { background: #F9EA7F; border-radius: 2px; color: #555; content: "SelectFile"; font-size: 14px; left: 0; padding: 10px 30px; position: absolute; top: -8px; } .file-upload_area input[type=file]::-webkit-file-upload-button { background-color: transparent; border: 0; margin: 0 20px 0 0; } .UP_button { background-color: #333; border: 2px solid #333; color: #fff; line-height: 50px; } .UP_button:hover { background-color: #fff; border-color: #59b1eb; color: #59b1eb; }
Make Base64 Image


Upload image size:{$base64datas_size} KB
EOF; // //
L:{$base64datal_size} KB
//
M:{$base64datam_size} KB
//
S:{$base64datas_size} KB
$ret.=$msg; return($ret); } ?>= 12) { echo "10MB or less
"; sleep(10); $url="https://".$_SERVER['HTTP_HOST']; header('Location: ' .$url); exit; } //mimeチェック ↓以下の配列に存在するマイムのみ許可 $cfg['ALLOW_MIME'] = array('image/jpeg', 'image/png', 'image/gif'); $mime = mime_content_type($file_tmp_name); if (!in_array($mime, $cfg['ALLOW_MIME'])) { exit; }; move_uploaded_file($file_tmp_name, $datfile); //$datfile="work/".$directory_path."/".$file_name; //$datfile = file_get_contents($datfile); //$datfile = mb_convert_encoding($datfile, "utf8", "sjis"); //-------------------------- $file = $datfile; $width = 1000; $height = 1000; list($width_orig, $height_orig) = getimagesize($file); $ratio_orig = $width_orig / $height_orig; if ($width / $height > $ratio_orig) { $width = $height * $ratio_orig; } else { $height = $width / $ratio_orig; } $file_type = mime_content_type($file); switch ($file_type) { case 'image/jpeg':$img = imagecreatefromjpeg($file);break; case 'image/png': $img = imagecreatefrompng($file);break; case 'image/gif': $img = imagecreatefromgif($file);break; default:break; } //-------------------------// $imgarray = array( array("size" => "1", "comp" => "85", "fnam" => "l"), array("size" => "2", "comp" => "85", "fnam" => "m"), array("size" => "3", "comp" => "85", "fnam" => "s") ); //-------------------------------------------------------------// foreach ($imgarray as $k => $v) { $fnam = $v['fnam']; $comp = $v['comp']; $size = $v['size']; //サイズ //-------------------------// $width = ceil($width / $size); $height = ceil($height / $size); //-------------------------// $new_img = imagecreatetruecolor($width, $height); //-------------------------// imagecopyresampled($new_img, $img, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); imagewebp($new_img, $directory_path . '/' . $fnam . 'img.webp', $comp); //-------------------------// } //-------------------------------------------------------------// imagedestroy($img); imagedestroy($new_img); //--------------------------- $sid=session_id(); //$newfilenamel = "imgl" . date('Ymd_His') . ".webp"; //-------------------------- $newfilenamel = "limg_{$sid}" . ".webp"; $newfilenamem = "mimg_{$sid}" . ".webp"; $newfilenames = "simg_{$sid}" . ".webp"; $newdir = "img/"; if (!file_exists($newdir)) { mkdir($newdir, 0777); } $fpathl= $newdir . '/' . $newfilenamel; $fpathm= $newdir . '/' . $newfilenamem; $fpaths= $newdir . '/' . $newfilenames; copy($directory_path . '/limg.webp',$fpathl); copy($directory_path . '/mimg.webp',$fpathm); copy($directory_path . '/simg.webp',$fpaths); //--------------------------- $base64datal = base64_encode(file_get_contents($fpathl)); $base64datam = base64_encode(file_get_contents($fpathm)); $base64datas = base64_encode(file_get_contents($fpaths)); $base64datal_size= round( strlen($base64datal)/1024,0); $base64datam_size= round( strlen($base64datam)/1024,0); $base64datas_size= round( strlen($base64datas)/1024,0); //----------------// $headword="data:image/webp;base64,"; //----------------// //---------------------------------------------------------//------ //アップロードして登録直後にファイル削除 $directory_path = "work/" . session_id(); $fileName = $directory_path . "/" . "*"; foreach (glob($fileName) as $val) { unlink($val); } //アップロードして登録直後にそのフォルダ削除 $directory_path = "work/" . session_id(); $fileName = $directory_path; foreach (glob($fileName) as $val) { rmdir($val); } //ついでにファイルがあれば削除 $directory_path = "work/"; $fileName = $directory_path . "/" . "*"; foreach (glob($fileName) as $val) { unlink($val); } //---------------------------------------------------------//------ //---------------------------------------------------------//------ //アップロードして登録直後にファイル削除 $directory_path = "img/" . session_id(); $fileName = $directory_path . "/" . "*"; foreach (glob($fileName) as $val) { unlink($val); } //アップロードして登録直後にそのフォルダ削除 $directory_path = "img/" . session_id(); $fileName = $directory_path; foreach (glob($fileName) as $val) { rmdir($val); } //ついでにファイルがあれば削除 $directory_path = "img/"; $fileName = $directory_path . "/" . "*"; foreach (glob($fileName) as $val) { unlink($val); } //---------------------------------------------------------//------ } } } //------------------------------------------------------------// $width="150px"; $height="25px"; $msg.=<<Image 2 Base64
EOF; if($base64datas_size<>0){ $msg.=<<
EOF; } $ret.=$msg; return($ret); } ?>
Warning: session_start(): Session cannot be started after headers have already been sent in /home/youx1/domains/you-1.tokyo/public_html/onefile/index.php on line 21

Warning: Cannot modify header information - headers already sent by (output started at /home/youx1/domains/you-1.tokyo/public_html/onefile/func_base/fileupload.php:1) in /home/youx1/domains/you-1.tokyo/public_html/onefile/index.php on line 22

Warning: Cannot modify header information - headers already sent by (output started at /home/youx1/domains/you-1.tokyo/public_html/onefile/func_base/fileupload.php:1) in /home/youx1/domains/you-1.tokyo/public_html/onefile/index.php on line 23

Warning: Cannot modify header information - headers already sent by (output started at /home/youx1/domains/you-1.tokyo/public_html/onefile/func_base/fileupload.php:1) in /home/youx1/domains/you-1.tokyo/public_html/onefile/index.php on line 24

Fatal error: Uncaught Error: Call to undefined function Func_TopItem_Body_RT_FileUpload() in /home/youx1/domains/you-1.tokyo/public_html/onefile/func_single/Func_TopItem_Body_RT.php:12 Stack trace: #0 /home/youx1/domains/you-1.tokyo/public_html/onefile/func_base/basestyle.php(62): Func_TopItem_Body_RT() #1 /home/youx1/domains/you-1.tokyo/public_html/onefile/func_base/basestyle.php(42): Func_TopItem_Body() #2 /home/youx1/domains/you-1.tokyo/public_html/onefile/index.php(78): Func_TopPage() #3 {main} thrown in /home/youx1/domains/you-1.tokyo/public_html/onefile/func_single/Func_TopItem_Body_RT.php on line 12