<?php
$content = "";
$fp = fopen("http://file-to-download.com/a-file.zip", "rb");
if (!$fp)
die("Error opening file.");
while (!feof($fp))
$content .= fread($fp, 2048);
fclose($fp);
$fp=fopen("local-file-name.zip", "w");
fwrite($fp, $content);
fclose($fp);
?>
Felix 發表在 痞客邦 留言(0) 人氣(431)
首先要講下 at 命令 是要用 /bin/bash shell 來執行的,
你可以在php裡查一下 apache 使用的是哪個 shell,
<?
$output = shell_exec('echo $SHELL');
echo $output;
?>
centos 預設 apache 的 shell 是 /bin/nologin
在linux 裡改
usermod -s /bin/bash apache
這樣就可以apache 就可以使用 at 了
由於at指令不同其他,不能用shell_exec執行,所以用以下方法
<?php
$r = popen('/usr/bin/at noon',"w");
fwrite($r,"ls -l");
pclose($r);
?>
搞定
Felix 發表在 痞客邦 留言(0) 人氣(482)
Felix 發表在 痞客邦 留言(0) 人氣(102)
通常
傳入參數是
function test(obj){
a=obj.style.pixelLeft
b=obj.style.pixelTop
}
*obj是網頁上的物件
但是
我認為比較好懂的方法是
function test(objID){
var obj = document.getElementById(objID);
a=obj.style.pixelLeft
b=obj.style.pixelTop
}
Felix 發表在 痞客邦 留言(0) 人氣(610)
function httpGet(theUrl){var xmlHttp =null;
xmlHttp =newXMLHttpRequest();
xmlHttp.open("GET", theUrl,false);
xmlHttp.send(null);return xmlHttp.responseText;}
Felix 發表在 痞客邦 留言(0) 人氣(7)
This is because
images and
tmp_file_upload are only writable by
root user. For upload to work we need to make the owner of those folders same as httpd process owner OR make them globally writable (bad practice).
Check apache process owner: ps aux | grep httpd. The first column will be the owner typically it will be nobody
Change the owner of images and tmp_file_upload to be become nobody or whatever the owner you found in step 1.
$sudo chown nobody /var/www/html/mysite/images/
$sudo chown nobody /var/www/html/mysite/tmp_file_upload/
Chmod images and tmp_file_upload now to be writable by the owner, if needed [Seems you already have this in place]. Mentioned in @Dmitry Teplyakov answer.
$ sudo chmod -R 0755 /var/www/html/mysite/images/
$ sudo chmod -R 0755 /var/www/html/mysite/tmp_file_upload/
For more details why this behavior happend, check the manual http://php.net/manual/en/ini.core.php#ini.upload-tmp-dir , note that it also talking about open_basedir directive.
Felix 發表在 痞客邦 留言(0) 人氣(117)
上傳多個檔案
可以對
input 功能變數使用不同的
name 來上傳多個檔案。
PHP 支援同時上傳多個檔案並將它們的訊息自動以陣列的形式組織。要完成這項功能,需要在 HTML 表單中對檔案上傳功能變數使用和多選框與復選框相同的陣列式送出語法。
注: 對多檔案上傳的支援是在 PHP 3.0.10 版本增加的。
例子 38-4. 上傳多個檔案
<form action="file-upload.php" method="post" enctype="multipart/form-data">
Send these files:<br />
<input name="userfile[]" type="file" /><br />
<input name="userfile[]" type="file" /><br />
<input type="submit" value="Send files" />
</form>
|
|
當以上表單被送出後,陣列
$_FILES['userfile'],
$_FILES['userfile']['name'] 和
$_FILES['userfile']['size'] 將被起始化(在 PHP 4.1.0 以前版本是
$HTTP_POST_FILES)。若果
register_globals 的設定為 on,則和檔案上傳關聯的全局變量也將被起始化。所有這些送出的訊息都將被儲存到以數字為索引的陣列中。
例如,假設名為
/home/test/review.html 和
/home/test/xwp.out 的檔案被送出,則
$_FILES['userfile']['name'][0] 的值將是
review.html,而
$_FILES['userfile']['name'][1] 的值將是
xwp.out。類似的,
$_FILES['userfile']['size'][0] 將包括檔案
review.html 的大小,依此類推。
此外也同時設定了
$_FILES['userfile']['name'][0],
$_FILES['userfile']['tmp_name'][0],
$_FILES['userfile']['size'][0] 以及
$_FILES['userfile']['type'][0]。
Felix 發表在 痞客邦 留言(0) 人氣(2,287)
首先說一下document對象的來歷。在瀏覽器訪問的任何一個頁面,都會在內存中以XML的形式存在一個副本,瀏覽器遵循一個內部算法將HTML轉成XML,這種XML,javascript可以直接訪問,重要的是,它可以被修改並立即在瀏覽器中實現。
簡單的說DOM就是用來表示XML的元素,我們使用一個名為document來引用它,基於這個實例,我們可以查詢每個XML元素,即Element對象。
在WEB中,如果我們指定了某個元素的屬性「id=」,就可以使用Document對象的成員方法getElementByID()來檢索這個元素。
代碼=======================
<td>
<IMG id ="2XSHZ" >
</td>
<script language="javascript" >
var i = Math.random();
document.getElementById("2XSHZ").src="2XSHZ.jpg?i="+i;
</script>
Felix 發表在 痞客邦 留言(0) 人氣(1,995)

【實作 Server 端】
所謂 Server-Sent Event 中文解釋為伺服器推送或伺服器推播,主要是用來將伺服器上的資料自動傳輸至 Client 端,使用的是 HTTP 通訊協定。首先需要 Server 端的應用程式,筆者以 ASP.NET 泛型處理常式來實作本文 Server 端的應用程式,您也可以利用 PHP、JSP 等其他 Server 端的程式語言來實作。
Server 端的程式推送給 Client 端的封包是由
event(事件或識別名稱,預設值為 message)、
data(要傳送給 Client 端的資料內容)、
id(Server 端推送資料到 Client 端時的事件ID) 和
retry(以毫秒為單位,用來定義兩次要求之間的間隔時間)等四個欄位所組成,其格式為【
欄位名稱:欄位內容】。其中又以
data 欄位最為重要,若 Server 端沒有傳送該欄位給 Client 端,即便您定義了資料接收的事件,該事件仍不會被觸發。
Felix 發表在 痞客邦 留言(0) 人氣(363)
$('body').css('background-image','url(../images/backgrounds/header-top.jpg)');
Felix 發表在 痞客邦 留言(0) 人氣(2,254)