2015年6月18日 星期四

php改變上傳後圖檔的長寬尺寸

<?php


if(is_uploaded_file($upload1))

//upload1為上傳圖檔input 欄位內的name""
          {
          if($_FILES['upload1']!="none")  {      
                //resize 390*250  518×351  2
$uploadedfile = $_FILES['upload1']['tmp_name'];
$src = imagecreatefromjpeg($uploadedfile);
list($width,$height)=getimagesize($uploadedfile);
$newwidth=390 ;
$newheight=($height/$width)*$newwidth;
$tmp=imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); 

                $fnsub=explode(".",$_FILES['upload1']['name']);

                if($fnsub[1]!="") {
                $fn1="bbs_".date("Ymdhis").".".$fnsub[1];
                copy($_FILES['upload1']['tmp_name'],$DOCUMENT_ROOT."/upimg/$fn1");
             
                imagejpeg($tmp,$DOCUMENT_ROOT."/upimg/$fn1",100);
                imagedestroy($src);
imagedestroy($tmp);
             }                  

          } 


?>

2014年8月17日 星期日

使IE不再跳出「Internet Explorer已限制這個網頁執行指令碼或ActiveX控制項」這個警告列,IE上的Mark of the Web (MOTW)

當在本機、隨身碟或CD光碟上以IE執行網頁html檔案時,
如果html檔案有使用javascript語法,那麼IE就會跳出
「Internet Explorer已限制這個網頁執行指令碼或ActiveX控制項」
這樣的警告列,必須按下「允許被封鎖的內容」按鈕,才能順利執行。
如果想把網頁燒在光碟上讓使用者瀏覽,就會遇到這樣的問題。

這時可以在html碼內加入下面這段語法,來避免這樣的情形發生

<!DOCTYPE html>
<!-- saved from url=(0014)about:internet -->
<html>
<head>

微軟網站對於Mark of the web的說明

使用時注意:
根據stackoverflow網站harrygg網友的回覆
"make sure the HTML file is saved in windows/dos format with "\r\n" as line breaks after the statement. Otherwise I couldn't make it work."

筆者使用apple電腦做網頁的coding,加上MOTW語法的html檔案拿到pc上去用,就沒有作用,還是會出現警告,後來在pc上新增文字檔把語法都copy貼上,另外重新存html檔案,就可以了,大概就是上方harrygg網友所說的格式問題。




2014年4月22日 星期二

ckeditor 固定編輯視窗的大小,讓使用者無法拉動區塊改變尺寸

修改config.js檔案:
在CKEDITOR.editorConfig = function( config ){  }
內加上

//設定視窗高度及寬度

config.height = '111px'; //可以這樣寫
config.width = 111; //也可以這樣寫
//關閉尺寸縮放,固定尺寸,讓使用者無法拉動區塊改變尺寸

config.resize_enabled = false;
//也可以不關閉尺寸縮放的功能,但是控制縮放的方向(垂直或水平),以及最大及最小的縮放範圍

config.resize_dir = 'vertical'; //可以設定 (both, vertical,或是 horizontal)