Ads 468x60px

Pages

2010年4月13日 星期二

[PHP] upload file 的同時,存取其他的 parameters

幾天前,被問到 html form 在 upload file 的同時,如何存取其他的參數?太久沒寫 code ,一時也無法確定,所以寫了個測試程式。結果是可以用 $_POST 拿到。

[upload_form.html]
------
....

form action="http://192.168.0.1:80/ws/uploadFile" enctype="multipart/form-data" method="post"
input name="t" type="hidden" value="1271143058" 
input name="expire" type="hidden" value="1271143063" 
input name="routerAccessKeyId" type="hidden" value="05f6adb19e46f06ef0515f24e2dc586e" 
input name="sig" type="hidden" value="e53a274015c4ab6670faa98775827c3b" 
input name="path" type="hidden" value="/usb1/muchiii/photo" 
input name="callback" type="hidden" value="_getdata_123456" 

input name="filename" type="file" 
...
...
------

[uploadFile.php]
------
var_dump($_POST);
print "\n";
var_dump($_FILES);
------

得到以下結果。
------
array(6) {
  ["t"]=>
  string(10) "1271143058"
  ["expire"]=>
  string(10) "1271143063"
  ["routerAccessKeyId"]=>
  string(32) "05f6adb19e46f06ef0515f24e2dc586e"
  ["sig"]=>
  string(32) "e53a274015c4ab6670faa98775827c3b"
  ["path"]=>
  string(19) "/usb1/muchiii/photo"
  ["callback"]=>
  string(15) "_getdata_123456"
}

array(1) {
  ["uploadedfile"]=>
  array(5) {
    ["name"]=>
    string(18) "OverallSystem1.png"
    ["type"]=>
    string(9) "image/png"
    ["tmp_name"]=>
    string(14) "/tmp/phpNbiLMY"
    ["error"]=>
    int(0)
    ["size"]=>
    int(86265)
  }
}
------

2010年2月2日 星期二

USB SATA 外接硬碟如何在 Mac OS & Windows XP 之間共享及讀寫

之前把這顆 USB SATA 硬碟,格式化成 Mac OS Extended Journaled,然後,用在 2 台 macbook pro 之間透過 rsync 做備份及同步我的 home directory,沒有什麼大的問題。

有天,想要把我另一台 Windows XP 上 download 下來的電影檔要 copy 到 MacbookPro,發現 Windows XP 竟然認不得這顆外接 USB 硬碟;原來,Windows XP 是認不得 "Mac OS Extended Journaled" 的檔案格式,只好來將它 format 成 FAT32 格式。

之後,將 USB 硬碟做了第二份備份之後,就把它放在 MacbookPro 裡,格式化成 FAT32。接下來,接到 Windows XP 的電腦上。看起來是可以用了,可是之後發現了另一個問題,就是 FAT32 格式,不支援單一檔案超過 4GB;只有 NTFS 可以支援,可是 Mac OS 又不認得 NTFS 格式(Leopard 之前,縱使認得,也只能讀,不能寫)。那到底我要用什麼格式呢?

在考量這顆外接 USB 硬碟的穩定性(“建達“出奇蛋,果然是蛋,很脆弱),就放棄它當做 MacbookPro 的備份硬碟,而拿它來做為 Windows XP 下的第三顆硬碟。

即然要 format 成 NTFS,當然就選擇在 Windows XP 下進行;在著手 format 它的過程中,又發現,它有一個奇怪的分割區,叫做“GPT保護的磁碟分割“,沒有辦法刪除它;google 了一下,發現原來它是 Vista or Windows 7 額外建出來的 partition,用來保護資料用的;不過在 Windows XP 下,它是沒有作用的,所以就想辦法來刪除它。以下是刪除它的方法

==================================================================
Windows XP → 開始 → 執行 → diskpart

接著輸入 list disk 查看所有磁碟機編號

選擇你要修改的磁碟, 假設是 disk 1, 就輸入 select disk 1 來選擇 磁碟#1

最後在輸入 clean

搞定
==================================================================

之後,再到 「控制台」-「系統管理工具」-「電腦管理」做 partition 及 format 成 NTFS 即可。

當當當,接下來,這顆 USB 外接硬碟雖然在 mac 端可以讀取,但是卻不能寫入。有二個方式:

1. MacFUSE + NTFS-3G
2. NTFS Mounter

二種方式,都各有利幣,就看你的需求而定囉!基本上,我會以「讀取」為主,偶而用用「寫入」,所以我選 NTFS Mounter.

2010年1月22日 星期五

Mac OS X Server v10.6: Starting up with the 32-bit or 64-bit kernel

Summary

Mac OS X Server v10.6 Snow Leopard includes a new 64-bit kernel that increases performance and scalability on supported hardware. On hardware that supports the 64-bit kernel, you can choose whether to start up (boot) your server using the new 64-bit kernel or the earlier 32-bit kernel.

Note: To determine whether or not your server can use the 64-bit kernel, and which kernel it uses by default, see this article.

Products Affected
Mac OS X Server 10.6

You can use either of these methods:

Method 1: Startup key combination (for current startup only)

  • If your server uses the 32-bit kernel by default, but supports the 64-bit kernel, you can start up using the 64-bit kernel by holding the 6 and 4 keys during startup.
  • If your server uses the 64-bit kernel by default, you can start up with the 32-bit kernel by holding the 3 and 2 keys during startup.

Your server will revert to the default kernel the next time you reboot it.

Method 2: On-disk setting (persistent)

To select the 64-bit kernel for the current startup disk, use the following command in Terminal:
sudo systemsetup -setkernelbootarchitecture x86_64

To select the 32-bit kernel for the current startup disk, use the following command in Terminal:
sudo systemsetup -setkernelbootarchitecture i386

Note: This setting is stored in the /Library/Preferences/SystemConfiguration/com.apple.Boot.plist file and will take effect every time you start up from this disk. If you start up from a different disk, the setting on that disk, or the hardware default, will take effect.

Additional Information

  • Keys held during startup (such as 3-2 or 6-4, method 1 above) will override the setting in com.apple.Boot.plist (method 2 above).

如何克服公司檔我 facebook on MacBook

Configure Routing Table For Facebook in MAC OSX by Kevin.L

It's very troublesome while you need to access both Facebook and internal resources.
You need to switch internet connection to acheive this manually.
You only need to execute the following command in TERMINAL.
After that you don't have to switch between connections anymore.
PS: You need to connect to wireless SSID: muchiii_lab_dir685(hinet) first.

sudo route  add -net 69.63 192.168.0.1 255.255.0.0

關機時,自動設定
1. 增加一個目錄 AddRoutes 到 /Library/StartupItems/
2. 在 AddRoutes/ 目錄下,新增一個檔案叫 StartupParameters.plist
        Description     = "Add static routing tables";
        Provides        = ("AddRoutes");
        Requires        = ("Network");
        OrderPreference = "None";

3. 在 AddRoutes/ 目錄下,新增一個檔案叫 AddRoutes (沒錯,它跟目錄名稱一樣)
#!/bin/sh
# Set up static routing tables
# Roark Holz, Thursday, April 6, 2006

. /etc/rc.common

StartService ()
{
        ConsoleMessage "Adding Static Routing Tables"
        /sbin/route add -net 69.63 192.168.0.1 255.255.0.0
        /sbin/route add -net 66.220 192.168.0.1 255.255.0.0
}

StopService ()
{
        return 0
}

RestartService ()
{
        return 0
}

RunService "$1"

2009年9月21日 星期一

Mac 內建的 GarageBand 自製 iPhone 手機鈴聲

基本操作

1. 先準備好要拿來製作成鈴聲的音樂檔案,MP3 就可以了!不用事先轉換成 AAC 的格式。
2. 開啟應用程式中的 GarageBand 軟體,選擇 製作新音樂計畫,然後直接按下 製作 按鈕,這時會出現只有一個音軌的新音樂。


3. 將要製作成鈴聲的音樂檔案從 Finder 資料夾中(或桌面上)直接將檔案拖曳進入到 GarageBand 的視窗中央空空的地方。這時就會出現第二個音軌來並且顯示音樂檔案的聲音波型。
4. 將這個音軌往左拖曳到最開頭的位置,按下視窗最下方的播放按鈕就可以播放音樂。播放時有一個小三角形和一條直直紅線所組成的定位點會隨著音樂正播放到的位置一起跑。


5. 視窗下方有一個 LCD 面板(在音樂播放控制按鈕的右側),顯示了目前正播放到第幾個小節和節拍。這時請專心的聆聽正在播放的音樂,記住你想要擷取成手機鈴聲的那一小段音樂是從第幾個小節和節拍開始的。

TIPS: 點兩下第二個音軌(也就是音樂的波型圖案),可以將波型圖案放大來看,更容易找到要擷取音樂準確的位置。



擷取出 40 秒的音樂

6. 因為 iPhone 規定手機鈴聲不可以超過 40 秒,所以如果你想要查看秒數而不是節拍的話,可以從主選單選擇 控制->在 LCD 中顯示時間。這時音軌的單位和 LCD 面板中都會變成分鐘和秒數。


7. 在視窗最上方時間(或節拍)刻度的地方點一下,會將小三角形和一條直直紅線所組成的定位點移動到該位置。你也可以拖曳小三角形來移動定位點。
8. 先將定位點移動你所要擷取的鈴聲開始的位置。移動好後按下視窗下方的播放按鈕可以聆聽音樂,看看位置是否如同你所想要的一樣。如果不是的話就繼續調整定位點,直到定位點和紅線指在鈴聲開始的地方。

TIPS: 調整視窗下方大波型的定位點,會更精確。

TIPS: 有時看小節節拍會更容易抓到音樂中節奏和唱歌較精準的開始位置,從主選單選擇 控制->在 LCD 中顯示小節 能夠再次切換刻度為小節節拍。

9. 好了之後點選一下第二個音軌(也就是波型圖案),然後從主選單選擇 編輯->分割。這時就會將整首音樂在定位點的地方一分為二。

TIPS: 沒有選取音軌的話,是無法選擇分割的。

10. 先在視窗內空白的地方點一下,然後點選第二個音軌(也就是波型圖案)定位點左側的部分。這部份是我們不要的,從主選單選擇 編輯->刪除 將它移除掉。


11. 將剩下的音軌波型圖案,往左拖曳到最開頭的位置,
12. 重複和之前相同的步驟,將定位點移動你所要剪輯的鈴聲結束的位置。反覆聆聽和調整直到定位點的位置正確無誤為止,請注意鈴聲的總長度不要超過 40 秒哦!
13. 好了之後點選一下第二個音軌(也就是波型圖案),然後從主選單選擇 編輯->分割。再次將音樂在定位點的地方一分為二。
14. 先在視窗內空白的地方點一下,然後點選第二個音軌(也就是波型圖案)定位點右側的部分。這部份也是我們不要的,從主選單選擇 編輯->刪除 將它移除掉。


15. 如此一來擷取鈴聲的部份就完成了!請再次檢查音樂總長度不要超過 40 秒哦!如果超過的話你可能需要再重複前面的步驟,將不要的部份分割、刪掉,讓鈴聲擷取的更短一點。

將鈴聲傳送到 iTunes

16. 鈴聲音樂的部份確定沒問題後,從主選單選擇 共享->將鈴聲傳送到 iTunes


17. 不論你擷取的鈴聲多短,這時都會出現說你的鈴聲需要調整長度,按下 調整 按鈕。


18. 然後在視窗上方刻度的下面,會多出一條黃色的橫條,拖曳這個黃色橫條的最右方,將它移動到和你的鈴聲結尾相同的位置。
19. 如果黃色橫條的開頭並不是在視窗的最左方(0 秒的位置),請拖曳黃色橫條的最左方,將它往左移動到最開頭的位置。


TIPS: 黃色橫條就是鈴聲真正的長度,一樣不能超過 40 秒,可以剛好 40 秒。

20. 再次從主選單選擇 共享->將鈴聲傳送到 iTunes,就會開始自動幫你轉換、拷貝檔案到 iTunes。完成後在 iTunes 的鈴聲裡面便能夠看到這個新製作出來的鈴聲歌曲了!
21. 建議在 在 iTunes 的鈴聲裡面,將這個新的歌曲改個名稱、歌手和專輯,日後歌曲多了比較容易管理。

將鈴聲傳送到 iPhone

22. 最後將 iPhone 接上電腦來同步,鈴聲就會傳送過去囉!

TIPS: 記得要勾選同步所有鈴聲哦!

23. 同步完成後,在 iPhone 上要選擇鈴聲的地方,便會出現 自訂 的鈴聲,也就是剛剛用 GarageBand 所製作的歌曲。