本文目錄一覽:
- 1、PHP高手請教,如何把相冊程序的相冊文件夾默認圖標改為自定義圖標?
- 2、php中怎樣得到客戶端的http請求header所有信息
- 3、如何添加php的build system
- 4、PHP 如何遍歷一個目錄 要求剛出來只顯示第一級的文件夾和文件 當點擊了文件夾的時候顯示下級文件 要代碼!
- 5、php怎麼刪除文件?
- 6、為什麼 編程創文件時說路徑無效
PHP高手請教,如何把相冊程序的相冊文件夾默認圖標改為自定義圖標?
可能是這樣
img src=\””.$root.”sysimg/file.gif\” border=\”0\” width=\”100\” height=\”80\”
—》
img src=\””.$rootdir.”/file.gif\” border=\”0\” width=\”100\” height=\”80\”
img src=\””.$root.”sysimg/dir.gif\” border=\”0\” width=\”100\” height=\”80\”
—》
img src=\””.$rootdir.”/dir.gif\” border=\”0\” width=\”100\” height=\”80\”
php中怎樣得到客戶端的http請求header所有信息
?php
$dir=$HTTP_GET_VARS[“dir”]; //…….取得上個頁面傳遞來的路徑
$file=$HTTP_GET_VARS[“file”]; //…….取得傳遞來的文件名
$url=parse_url($HTTP_REFERER); /*……取得前一頁面的URL地址,並將其放入一個數組中*/
if($url[host]!=$HTTP_HOST){echo “要下載本軟體請到a href=;東方小屋/a”;exit;} /*檢查來源網站是不是自己的網站,如果不是,返回「要下載本……」*/
if(empty($dir))$dir=”/”; //……如果路徑名為空,則為指定根目錄
if(empty($file)){echo “未指定要下載的文件!”;exit;} /*如果文件名為空,返回「未指定……」*/
$rootdir=”文件存放的根目錄”;//……你的下載路徑根目錄
$realurl=$rootdir.$dir; //…….取得你的下載目錄
chdir($realurl); //……將當前目錄轉到下載目錄中
if(!file_exists($file)){echo “對不起,此鏈接已經失效,請在下載頁面上向我們報告,謝謝!”;exit;} //……測試文件是否存在
$filename=$file;
//發送文件頭信息
header(“Cache-control: private”); // fix for IE
header(“Content-Type: application/octet-stream”);
header(“Content-Length: “.filesize($filename));
header(“Content-Disposition: attachment; filename=$filename”);
$fp = fopen($filename, ‘r’); // 以讀取方式打開指定文件
fpassthru($fp); // ** CORRECT ** 以二進位方式讀取文件
fclose($fp); // 關閉文件
?
如何添加php的build system
1、在*.rc文件中用setprop添加,例如在源碼android4.0\system\core\rootdir\etc\init.goldfish.rc中有以下內容:
setprop ARGH ARGH
setprop net.eth0.gw 10.0.2.2
setprop net.eth0.dns1 10.0.2.3
setprop net.gprs.local-ip 10.0.2.15
2、在PRODUCT_PROPERTY_OVERRIDES中添加,例如在源碼android4.0\build\target\product\core.mk中有以下內容:
PRODUCT_PROPERTY_OVERRIDES := \
ro.config.notification_sound=OnTheHunt.ogg \
ro.config.alarm_alert=Alarm_Classic.ogg
3、在system.prop文件中添加,例如在源碼android4.0\build\target\board\generic\system.prop中有以下內容:
rild.libpath=/system/lib/libreference-ril.so
rild.libargs=-d /dev/ttyS0
4、在buildinfo.sh文件中添加。例如在源碼android4.0\build\tools\buildinfo.sh中有以下內容:
echo “ro.build.version.release=$PLATFORM_VERSION”
echo “ro.build.date=`date`”
echo “ro.build.date.utc=`date +%s`”
PHP 如何遍歷一個目錄 要求剛出來只顯示第一級的文件夾和文件 當點擊了文件夾的時候顯示下級文件 要代碼!
把變數填充到模板就自己搞定了,難道遇到問題,就什麼都要別人給你搞定,自己能搞定的,就自己搞定。
?php
error_reporting(E_ALL ^ E_NOTICE);
@header(“Content-Type: text/html; charset=utf-8”);
if($_GET[‘rootdir’]){
$rootdir = $_GET[‘rootdir’];
}else{
$query = trim($_SERVER[‘QUERY_STRING’])!=”?queryCode($_SERVER[‘QUERY_STRING’]):array();
$rootdir = $query[‘rootdir’];
print_r($query);
echo ‘hr’;
$showpath = $query[‘showpath’];//選擇的路徑
$showpathData = explode(‘/’,$showpath);
$showpathData = array_diff($showpathData, array(”));
$showpathData = array_values($showpathData);
print_r($showpathData);
echo ‘hr’;
}
(!$rootdir || !is_dir($rootdir)) $rootdir = dirname(__FILE__);//定義默認根路徑
$levl=0;
$nowDir = $query[‘rootdir’].$query[‘showpath’];
!$nowDir $nowDir = $rootdir;
$queryData = array();
$queryData[‘rootdir’] = $rootdir;
function read_dir($path){
strpos($path,’..’) !== false exit(‘Forbidden’);
$return=array();
$return[‘dirs’]=array();
$return[‘files’]=array();
if(is_dir($path)){
$childs=@opendir($path);
while($child=@readdir($childs)){
if($child!=”.” $child!=”..” $child!=”” $child!=”Thumbs.db”){
if(is_dir(“$path/$child”)){
$return[‘dirs’][] = $child;
}else{
$return[‘files’][] = $child;
}
}
}
@closedir($childs);
}
count($return[‘dirs’]) sort($return[‘dirs’]);
count($return[‘files’]) sort($return[‘files’]);
return $return;
}
function levltext($levl){
$text=’ ‘;
for($i=0;$i$levl;$i++){
$text.=’|===’;
}
return $text;
}
function queryCode($query,$key=”){
//因為要把實際路徑用作參數來傳輸,為了安全,所以將參數加密
!$key $key = ‘******’;//加密密匙
//json_encode,json_decode需要PHP 5 = 5.2.0
if(is_array($query)){
return StrCode(json_encode($query),’ENCODE’,$key);
}else{
return json_decode(StrCode($query,’DECODE’,$key),TRUE);
}
}
function StrCode($string,$action=’ENCODE’,$key=”){
//base64+$key加解密
$string.=””;
$action != ‘ENCODE’ $string = base64_decode($string);
$code = ”;
$key = md5($key);
$keylen = strlen($key); $strlen = strlen($string);
for ($i=0;$i$strlen;$i++) {
$k = $i % $keylen;
$code .= $string[$i] ^ $key[$k];
}
return ($action!=’DECODE’ ? base64_encode($code) : $code);
}
function printTable($ePath=”){
global $showpathData,$queryData,$levl,$rootdir;
$dfData = read_dir($rootdir.’/’.$ePath);
$_tDir = $showpathData[$levl];
$levl++;
$levltext = levltext($levl);
foreach($dfData[‘dirs’] as $_dir){
$queryData[‘showpath’] = $ePath.’/’.$_dir;
$queryString = queryCode($queryData);
$ext = ($_dir == $_tDir)?’–‘:’++’;
?
tr
td?php echo $levltext.$ext;?a href=”??php echo $queryString;?”?php echo $_dir;?/a/td
/tr
?php
if($_dir == $_tDir){
printTable($ePath.’/’.$_dir);
}
}
foreach($dfData[‘files’] as $_file){
?
tr
td?php echo $levltext;? ?php echo $_file;?/td
/tr
?php
}
}
//=======================================================================
print EOT
form action=” method=get
當前打開:{$nowDir}br
主路徑:input value=”$rootdir” name=’rootdir’ size=70
input type=submit
/form
hr
table width=”100%” border=”1″ cellspacing=”0″ cellpadding=”0″
tr
td b路徑/b/td
/tr
EOT;
printTable();
print EOT
/table
EOT;
?
php怎麼刪除文件?
刪除文件可以相對路徑,也可以絕對路徑,從你圖片2來看,報錯的信息是許可權不夠,沒有許可權刪除”./”,這說明你後面的值沒有獲取到。而它沒有許可權刪除它所在的目錄。
刪除文件注意兩點。
文件路徑是否存在,可以通過file_exist判斷。
文件許可權是否足夠。
為什麼 編程創文件時說路徑無效
$RootDir = $_SERVER[‘DOCUMENT_ROOT’];
$fileDir = $RootDir.’\phpDemo\fopen.txt’;
這個方法是首先定義了根目錄,再寫出文件的絕對路徑,通用也方便管理。
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/198311.html