jpgの場合は、IEでは$_FILES['upload_image']['type'] == 'image/pjpeg'となるので注意
<!---------------------phpソース--------------------->
<?php
session_cache_limiter('none');
session_start();
require_once('./helper/method.php');
if($_FILES['upload_image']['name']){
$msg = "OK";
$upload_dir = '../file/plan/pc/';
$upload_dir_sp = '../file/plan/sp/';
$filename = $_FILES['upload_image']['name'];
$uptime = date("YmdH_i_s");
$name = $_FILES['upload_image']['tmp_name'];
$flag= "";
//画像アップ処理
if($_FILES['upload_image']['type'] == 'image/jpeg' || $_FILES['upload_image']['type'] == 'image/pjpeg'){
$testmsg = '.jpg';
$upname = $upload_dir.$uptime.'.jpg';
$upname_sp = $upload_dir_sp.$uptime.'.jpg';
$judg = move_uploaded_file($_FILES['upload_image']['tmp_name'],$upname);
m_cpy_img($upname,$upname_sp);
}else
if($_FILES['upload_image']['type'] == 'image/gif'){
$upname = $upload_dir.$uptime.'.gif';
$upname_sp = $upload_dir_sp.$uptime.'.gif';
$judg = move_uploaded_file($_FILES['upload_image']['tmp_name'],$upname);
m_cpy_img($upname,$upname_sp);
}else
if($_FILES['upload_image']['type'] == 'image/ping'){
$upname = $upload_dir.$uptime.'.png';
$upname_sp = $upload_dir_sp.$uptime.'.png';
$judg = move_uploaded_file($_FILES['upload_image']['tmp_name'],$upname);
m_cpy_img($upname,$upname_sp);
}else{
$judg = false;
}
if($judg){
$msg = "OK";
smart_resize_image($upname,600,600,true);
smart_resize_image($upname_sp,300,200,true);
$dir = '/file/plan/pc/';
$_SESSION['input_data']['pl_img1'] = $dir.basename($upname);
}
}else{
$msg = "画像が選択されていません";
}
//************************************************
// ファイルコピー
//************************************************
function m_cpy_img($file_img_in,$file_img_out){
if ( file_exists( $file_img_in )) {
copy( $file_img_in, $file_img_out );
}
}
?>
<script type="text/javascript">
<!--
var flag = '<?php echo $msg; ?>';
if(flag == "OK"){
var container = parent.document.getElementById('container1');
image = parent.document.createElement('img');
image.src = '<?php if($upname){ print($upname); }else{ print("../file/photo/no-img.jpg"); }?>';
parent.document.planform.pl_img1.value='<?php if($upname){ print($upname); }?>';
container.innerHTML = '';
container.appendChild(image);
}else{
alert(flag);
}
//-->
</script>
</body>
</html>
<!-----------------HTML----------------------->
<tr>
<th>
プラン 料理画像※
</th>
<td>
<iframe name="uploader1" src="" style="width:0px;height:0px;border:0px;"></iframe>
<form action="uploader1.php" method="post" enctype="multipart/form-data" target="uploader1">
<input type="hidden" name="max_file_size" value="1000000" />
<input type="file" name="upload_image" />
<input type="submit" value="料理画像アップロード"/>
</form>
<!--------画像表示先---------->
<div id="container1">
{if $dataList.pl_img1}<img src="{$dataList.pl_img1}" id="pl_img1">{/if}
</div>
</td>
</tr>