文件上传错误信息说明
错误信息说明从 PHP 4.2.0 开始,
PHP 将随文件信息数组一起返回一个对应的错误代码。该代码可以在文件上传时生成的文件数组中的 error 字段中被找到,
也就是 $_FILES["userfile"]["error"]。
<?
/* 中文处理工具函数
--- 空格 ---
string GBspace(string) --------- 每个中文字之间加空格
string GBunspace(string) ------- 每个中文字之间的空格清除
string clear_space(string) ------- 用来清除多余的空格
--- 转换 ---
string GBcase(string,offset) --- 将字符串内的中英文字转换大小写
offset : "upper" - 字符串全转为大写 (strtoupper)
"lower" - 字符串全转为小写 (strtolower)
"ucwords" - 将字符串每个字第一个字母改大写 (ucwords)
"ucfirst" - 将字符串第一个字母改大写 (ucfirst)
string GBrev(string) ----------- 颠倒字符串
--- 文字检查 ---
int GB_check(string) ----------- 检查字符串内是否有 GB 字,有会返回 true,
否则会返回false
int GB_all(string) ------------- 检查字符串内所有字是否有 GB 字,是会返回 true,
否则会返回false
int GB_non(string) ------------- 检查字符串内所有字并不是 GB 字,是会返回 true,
否则会返回false
int GBlen(string) -------------- 返回字符串长度(中文字只计一字母)
--- 查找、取代、提取 ---
int/array GBpos(haystack,needle,[offset]) ---- 查找字符串 (strpos)
offset : 留空 - 查找第一个出现的位置
int - 由该位置搜索出现的第一个位置
"r" - 查找最后一次出现的位置 (strrpos)
"a" - 将所有查找到的字储存为数组(返回 array)
string GB_replace(needle,str,haystack) -- 查找与取代字符串 (str_replace)
string GB_replace_i(needle,str_f,str_b,haystack) -- 不检查大小写查找与取代字符串
needle - 查找字母
str - 取代字母 ( str_f - 该字母前, str_b 该字母后)
haystack - 字符串
string GBsubstr(string,start,[length]) -- 从string提取出由开始到结尾或长度
length的字符串。
中文字只计一字母,可使用正负数。
string GBstrnear(string,length) -- 从 string提取最接近 length的字符串。
length 中 中文字计2个字母。
--- 注意 ---
如使用由 Form 返回的字符串前,请先替字符串经过 stripslashes() 处理,除去多余的 \ 。
用法:在原 PHP 代码内加上:
include ("GB.inc");
即可使用以上工具函数。
*/
function GBlen($string) {
$l = strlen($string);
$ptr = 0;
$a = 0;
while ($a < $l) {
$ch = substr($string,$a,1);
$ch2 = substr($string,$a+1,1);
if (ord($ch) >= HexDec("0x81") && ord($ch2) >= HexDec("0x40")) {
$ptr++;
$a += 2;
} else {
$ptr++;
$a++;
} // END IF
} // END WHILE
return $ptr;
}
function GBsubstr($string,$start,$length) {
if (!is_int($length) && $length != "") {
return "错误:length 值错误(必须为数值)。<br>";
} elseif ($length == "0") {
return "";
} else {
$l = strlen($string);
$a = 0;
$ptr = 0;
$str_list = array();
$str_list2 = array();
while ($a < $l) {
$ch = substr($string,$a,1);
$ch2 = substr($string,$a+1,1);
if (ord($ch) >= HexDec("0x81") && ord($ch2) >= HexDec("0x40")) {
$str_list[$ptr] = $a;
$str_list2[$ptr] = $a+1;
$ptr++;
$a += 2;
} else {
$str_list[$ptr] = $a;
$str_list2[$ptr] = $a;
$ptr++;
$a++;
} // END IF
} // END WHILE
if ($start > $ptr || -$start > $ptr) {
return;
} elseif ($length == "") {
if ($start >= 0) { // (text,+)
return substr($string,$str_list[$start]);
} else { // (test,-)
return substr($string,$str_list[$ptr + $start]);
}
} else {
if ($length > 0) { // $length > 0
if ($start >= 0) { // (text,+,+)
if (($start + $length) >= count($str_list2)) {
return substr($string,$str_list[$start]);
} else { //(text,+,+)
$end = $str_list2[$start + ($length - 1)] - $str_list[$start] +1;
return substr($string,$str_list[$start],$end);
}
} else { // (text ,-,+)
$start = $ptr + $start;
if (($start + $length) >= count($str_list2)) {
return substr($string,$str_list[$start]);
} else {
$end = $str_list2[$start + ($length - 1)] - $str_list[$start] +1;
return substr($string,$str_list[$start],$end);
}
}
} else { // $length < 0
$end = strlen($string) - $str_list[$ptr+$length];
if ($start >= 0) { // (text,+,-) {
return substr($string,$str_list[$start],-$end);
} else { //(text,-,-)
$start = $ptr + $start;
return substr($string,$str_list[$start],-$end);
}
} // END OF LENGTH > / < 0
}
} // END IF
}
function GB_replace($needle,$string,$haystack) {
$l = strlen($haystack);
$l2 = strlen($needle);
$l3 = strlen($string);
$news = "";
$skip = 0;
$a = 0;
while ($a < $l) {
$ch = substr($haystack,$a,1);
$ch2 = substr($haystack,$a+1,1);
if (ord($ch) >= HexDec("0x81") && ord($ch2) >= HexDec("0x40")) {
if (substr($haystack,$a,$l2) == $needle) {
$news .= $string;
$a += $l2;
} else {
$news .= $ch.$ch2;
$a += 2;
}
} else {
if (substr($haystack,$a,$l2) == $needle) {
$news .= $string;
$a += $l2;
} else {
$news .= $ch;
$a++;
}
} // END IF
} // END WHILE
return $news;
}
function GB_replace_i($needle,$str_f,$str_b,$haystack) {
$l = strlen($haystack);
$l2 = strlen($needle);
$l3 = strlen($string);
$news = "";
$skip = 0;
$a = 0;
while ($a < $l) {
$ch = substr($haystack,$a,1);
$ch2 = substr($haystack,$a+1,1);
if (ord($ch) >= HexDec("0x81") && ord($ch2) >= HexDec("0x40")) {
if (GBcase(substr($haystack,$a,$l2),"lower") == GBcase($needle,"lower")) {
$news .= $str_f . substr($haystack,$a,$l2) . $str_b;
$a += $l2;
} else {
$news .= $ch.$ch2;
$a += 2;
}
} else {
if (GBcase(substr($haystack,$a,$l2),"lower") == GBcase($needle,"lower")) {
$news .= $str_f . substr($haystack,$a,$l2) . $str_b;
$a += $l2;
} else {
$news .= $ch;
$a++;
}
} // END IF
} // END WHILE
return $news;
}
function GBpos($haystack,$needle,$offset) {
if (!is_int($offset)) {
$offset = strtolower($offset);
if ($offset != "" && $offset != "r" && $offset != "a") {
return "错误:offset 值错误。<br>";
}
}
$l = strlen($haystack);
$l2 = strlen($needle);
$found = false;
$w = 0; // WORD
$a = 0; // START
if ($offset == "" || $offset == "r") {
$atleast = 0;
$value = false;
} elseif ($offset == "a") {
$value = array();
$atleast = 0;
} else {
$value = false;
$atleast = $offset;
}
while ($a < $l) {
$ch = substr($haystack,$a,1);
$ch2 = substr($haystack,$a+1,1);
if (ord($ch) >= HexDec("0x81") && ord($ch2) >= HexDec("0x40") && $skip == 0) {
if (substr($haystack,$a,$l2) == $needle) {
if ($offset == "r") {
$found = true;
$value = $w;
} elseif ($offset == "a") {
$found = true;
$value[] = $w;
} elseif (!$value) {
if ($w >= $atleast) {
$found = true;
$value = $w;
}
}
}
$a += 2;
} else {
if (substr($haystack,$a,$l2) == $needle) {
if ($offset == "r") {
$found = true;
$value = $w;
} elseif ($offset == "a") {
$found = true;
$value[] = $w;
} elseif (!$value) {
if ($w >= $atleast) {
$found = true;
$value = $w;
}
}
}
$a++;
}
$w++;
} // END OF WHILE
if ($found) {
return $value;
} else {
return $false;
}
// } // END OF WHILE
}
function GBrev($text) {
$news = "";
$l = strlen($text);
$GB = 0;
$a = 0;
while ($a < $l) {
$ch = substr($text,$a,1);
$ch2 = substr($text,$a+1,1);
if (ord($ch) >= HexDec("0x81") && ord($ch2) >= HexDec("0x40") && $skip == 0) {
$a += 2;
$news = $ch . $ch2 . $news;
} else {
$news = $ch . $news;
$a++;
}
}
return $news;
}
function GB_check($text) {
$l = strlen($text);
$a = 0;
while ($a < $l) {
$ch = substr($text,$a,1);
$ch2 = substr($text,$a+1,1);
if (ord($ch) >= HexDec("0x81") && ord($ch2) >= HexDec("0x40")) {
return true;
} else {
return false;
}
}
}
function GB_all ($text) {
$l = strlen($text);
$all = 1;
$a = 0;
while ($a < $l) {
$ch = substr($text,$a,1);
$ch2 = substr($text,$a+1,1);
if (ord($ch) >= HexDec("0x81") && ord($ch2) >= HexDec("0x40")) {
$a += 2;
} else {
$a++;
$all = 0;
}
}
if ($all == 1) {
return true;
} else {
return false;
}
}
function GB_non ($text) {
$l = strlen($text);
$all = 1;
$a = 0;
while ($a < $l) {
$ch = substr($text,$a,1);
$ch2 = substr($text,$a+1,1);
if (ord($ch) >= HexDec("0x81") && ord($ch2) >= HexDec("0x40")) {
$a += 2;
$all = 0;
} else {
$a++;
}
}
if ($all == 1) {
return true;
} else {
return false;
}
}
function GBcase ($text,$case) {
$case = strtolower($case);
if ($case != "upper" && $case != "lower" && $case != "ucwords" && $case != "ucfirst") {
return "函数用法错误。 $case";
} else {
$ucfirst = 0;
$ucwords = 0;
$news = "";
$l = strlen($text);
$GB = 0;
$english = 0;
$a = 0;
while ($a < $l) {
$ch = substr($text,$a,1);
if ($GB == 0 && ord($ch) >= HexDec("0x81")) {
$GB = 1;
$english = 0;
$news .= $ch;
$ucwords = 0;
} elseif ($GB == 1 && ord($ch) >= HexDec("0x40") && $english == 0) {
$news .= "$ch";
$ucwords = 0;
$GB = 0;
} else {
if ($case == "upper") {
$news .= strtoupper($ch);
} elseif ($case == "lower") {
$news .= strtolower($ch);
} elseif ($case == "ucwords") {
if ($ucwords == 0) {
$news .= strtoupper($ch);
} else {
$news .= strtolower($ch);
}
$ucwords = 1;
} elseif ($case == "ucfirst") {
if ($ucfirst == 0) {
$news .= strtoupper($ch);
$ucfirst = 1;
} else {
$news .= strtolower($ch);
$ucfirst = 1;
}
} else {
$news .= $ch;
}
if ($ch == " " || $ch == "\n") {
$ucwords = 0;
}
$english = 1;
$GB = 0;
}
$a++;
} // END OF while
return $news;
} // end else
}
function GBspace ($text) {
$news = "";
$l = strlen($text);
$GB = 0;
$english = 0;
$a = 0;
while ($a < $l) {
$ch = substr($text,$a,1);
$ch2 = substr($text,$a+1,1);
if (!($ch == " " && $ch2 == " ")) {
if ($GB == 0) {
if (ord($ch) >= HexDec("0x81")) {
if ($english == 1) {
if ((substr($text,$a-1,1) == " ") || (substr($text,$a-1,1) == "\n")) {
$news .= "$ch";
} else {
$news .= " $ch";
}
$english = 0;
$GB = 1;
} else {
$GB = 1;
$english = 0;
$news .= $ch;
}
} else {
$english = 1;
$GB = 0;
$news .= $ch;
}
} else {
if (ord($ch) >= HexDec("0x40")) {
if ($english == 0) {
if ((substr($text,$a+1,1) == " ")|| (substr($text,$a+1,1) == "\n")) {
$news .= "$ch";
} else {
$news .= "$ch ";
}
} else {
$news .= " $ch";
}
} else {
$english = 1;
$news .= "$ch";
}
$GB = 0;
}
}
$a++;
} // END OF while
// Chk 1 & last is space
$l = strlen($news);
if (substr($news,0,1) == " ") {
$news = substr($news,1);
}
$l = strlen($news);
if (substr($news,$l-1,1) == " ") {
$news = substr($news,0,$l-1);
}
return $news;
}
function GBunspace($text) {
$news = "";
$l = strlen($text);
$a = 0;
$last_space = 1;
while ($a < $l) {
$ch = substr($text,$a,1);
$ch2 = substr($text,$a+1,1);
$ch3 = substr($text,$a+2,1);
if (($a + 1) == $l ) {
$last_space = 1;
}
if ($ch == " ") {
if ($last_space == 0) {
if (ord($ch2) >= HexDec("0x81") && ord($ch3) >= HexDec("0x40")) {
if ($chi == 0) {
$news .= " ";
$last_space = 1;
}
$chi=1;
} elseif ($ch2 != " ") {
$news .= " ";
$chi = 0;
$last_space = 1;
}
}
} else {
if (ord($ch) >= HexDec("0x81") && ord($ch2) >= HexDec("0x40")) {
$chi = 1;
$a++;
$news .= $ch . $ch2;
$last_space = 0;
} else {
$chi = 0;
$news .= $ch;
$last_space = 0;
}
}
$a++;
}
// Chk 1 & last is space
$l = strlen($news);
if (substr($news,0,1) == " ") {
$news = substr($news,1);
}
$l = strlen($news);
if (substr($news,$l-1,1) == " ") {
$news = substr($news,0,$l-1);
}
return $news;
} // END OF Function
function GBstrnear($text,$length) {
$tex_len = strlen($text);
$a = 0;
$w = "";
while ($a < $tex_len) {
$ch = substr($text,$a,1);
$ch2 = substr($text,$a+1,1);
if (GB_all($ch.$ch2)) {
$w .= $ch.$ch2;
$a=$a+2;
} else {
$w .= $ch;
$a++;
}
if ($a == $length || $a == ($length - 1)) {
$a = $tex_len;
}
}
return $w;
} // END OF FUNCTION
function clear_space($text) {
$t = "";
for ($a=0;$a<strlen($text);$a++) {
$ch = substr($text,$a,1);
$ch2 = substr($text,$a+1,1);
if ($ch == " " && $ch2 == " ") {
} else {
$t .= $ch;
}
}
return $t;
}
?>
首先删除不必要的文件节省空间。凡是以_开头的文件如_samples,_testcases和一些用不到的.asp、.jsp、.cfm文件统统干掉。
2修改fckconfig.js
FCKConfig.AutoDetectLanguage = true ;//是否自动检测语言
FCKConfig.DefaultLanguage = 'zh-cn' ;//设置语言
FCKConfig.SkinPath = FCKConfig.BasePath + 'skins/default/' ;//设置皮肤
FCKConfig.TabSpaces = 1 ;//tab是否有效
FCKConfig.ToolbarStartExpanded = true ;//编辑工具条是否出现,等点“展开工具栏”时才出现
FCKConfig.FontNames = '宋体;黑体;隶书;楷体_GB2312;Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana' ;//添加中文字体
修改FCKeditor\editor\css\fck_editorarea.css
设置默认字体及大小
body, td
{
font-family: Arial, Verdana, Sans-Serif;
font-size: 14px;
}
3关于文件上传的设置
修改fckconfig.js
var _FileBrowserLanguage = 'php' ; // asp | aspx | cfm | lasso | perl | php
var _QuickUploadLanguage = 'php' ; // asp | aspx | cfm | lasso | php
修改fckeditor\editor\filemanager\browser\default\connectors\php
$Config['Enabled'] = true ;
$Config['UserFilesPath'] = '/UserFiles/' ;//设置上传的文件夹,可自己指定
修改fckeditor\editor\filemanager\upload\php
$Config['Enabled'] = true ;
$Config['UseFileType'] = true ;
$Config['UserFilesPath'] = '/UserFiles/' ;//同上要一样
4引入在线编辑器时只需
<?php
include("fckeditor/fckeditor.php") ;
$oFCKeditor = new FCKeditor('FCKeditor1') ;//实例化
$oFCKeditor->BasePath = 'fckeditor/';//这个路径一定要和上面那个引入路径一致,否则会报错:找不到fckeditor.html页面
//$oFCKeditor->Value = '' ;默认值
$oFCKeditor->Width = '100%' ; //宽度
$oFCKeditor->Height = '300' ; //fck
$oFCKeditor->Create() ;
?>
=================
取得数据
$sValue = addslashes( $_POST['FCKeditor1'] ) ;
显示数据stripslashes,原因是addslashes函数加'加上了\'而stripslashes取还原由addslashes处理的数.
foreach()有两种用法
1: foreach(array as $value)
{
表达式;
}
这里的array是你要遍历的数组名,每次循环中,array数组的当前元素的值被赋给$value,
并且数组内部的下标向下移一步,也就是下次循环回得到下一个元素
2:foreach(array_name as $key => $value)
{
表达式
}
这里跟第一种方法的区别就是多了个$key,也就是除了把当前元素的值赋给$value外,当前元素的键值也会在每次循环中被赋给变量$key。键值可以是下标值,也可以是字符串。比如book[0]=1中的“0”,book[id]="001"中的“id”.
其实两种的效率不相上下.
教你如何 配置 phpMyAdmin
下载:请到phpmyadmin官方站点 http://www.phpmyadmin.net/ 下载phpmyadmin文件,
解压后对phpmyadmin进行设置我边讲例子别解析:
解压后得到一个目录,与以前的版本不同,2.8版的phpMyAdmin 的根目录中没有名为 config.inc.php 的配置文件,现在的配置文件是 libraries/config.default.php 进在该文件中
我的目录为:http://www.111cn.net/myadmin/
找到 $cfg['PmaAbsoluteUri']
修改你将上传到空间的phpMyAdmin的网址
如:$cfg['PmaAbsoluteUri'] = 'http://yoursite/phpmyadmin/';
还有下面的
$cfg['Servers'][$i]['host'] = 'localhost';(通常用默认, 也可能是主机IP)
$cfg['Servers'][$i]['host'] = 'localhost;这里是默认的我们一般不改
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '******';
为了安全起见我们找到设置$cfg['Servers'][$i]['auth_type'] = ''修改值勤cookie
$cfg['Servers'][$i]['auth_type'] = 'cookie'; // Authentication method (config, http or cookie based)?
config: 按照 自身 libraries/config.default.php 文件中的配置提供用户名和密码
cookie:用于输入口令方式登陆,如果选择此项,需要设置$cfg['blowfish_secret'] = 'cookie';(见后面的介绍)
$cfg['Servers'][$i]['user'] = 'root'; // MySQL user(用户名,自己机里用root,在网上设你的mysql用户名)
$cfg['Servers'][$i]['password'] = ''; // MySQL password (only needed
自己机里不用设
$cfg['Servers'][$i]['only_db'] = ''; // If set to a db-name, only(你只有一个数据就设置一下)
注:$cfg['blowfish_secret'] = '';
本机的话不需要设置,但是网络的话需要设置成cookie:
$cfg['blowfish_secret'] = 'cookie';
设置完毕可以上传到网上了。
浏览http://yoursite//phpmyadmin/ 当然你设置不同就用那个网址。
如果设置$cfg['Servers'][$i]['auth_type'] = 'cookie'; 所以显示会要求输入帐号密码,这里的帐号和密码你在提供商获得的mysql数据库的帐号、密码。
好了,就这么简单,对新手应该有一点点帮助.
相关文章
- 下面小编来给大家演示几个php操作zip文件的实例,我们可以读取zip包中指定文件与删除zip包中指定文件,下面来给大这介绍一下。 从zip压缩文件中提取文件 代...2016-11-25
Jupyter Notebook读取csv文件出现的问题及解决
这篇文章主要介绍了JupyterNotebook读取csv文件出现的问题及解决,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教...2023-01-06- 有时我们接受或下载到的PSD文件打开是空白的,那么我们要如何来解决这个 问题了,下面一聚教程小伙伴就为各位介绍Photoshop打开PSD文件空白解决办法。 1、如我们打开...2016-09-14
- 这篇文章主要介绍了解决python 使用openpyxl读写大文件的坑,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-03-13
- 这篇文章主要介绍了C#实现HTTP下载文件的方法,包括了HTTP通信的创建、本地文件的写入等,非常具有实用价值,需要的朋友可以参考下...2020-06-25
- 这篇文章主要为大家详细介绍了SpringBoot实现excel文件生成和下载,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-02-09
- C#使用System.IO中的文件操作方法在Windows系统中处理本地文件相当顺手,这里我们还总结了在Oracle中保存文件的方法,嗯,接下来就来看看整理的C#操作本地文件及保存文件到数据库的基本方法总结...2020-06-25
php无刷新利用iframe实现页面无刷新上传文件(1/2)
利用form表单的target属性和iframe 一、上传文件的一个php教程方法。 该方法接受一个$file参数,该参数为从客户端获取的$_files变量,返回重新命名后的文件名,如果上传失...2016-11-25- 本文章来人大家介绍一个php文件上传类的使用方法,期望此实例对各位php入门者会有不小帮助哦。 简介 Class.upload.php是用于管理上传文件的php文件上传类, 它可以帮...2016-11-25
- 要替换字符串中的内容我们只要利用php相关函数,如strstr,str_replace,正则表达式了,那么我们要替换目录所有文件的内容就需要先遍历目录再打开文件再利用上面讲的函数替...2016-11-25
- 又码了一个周末的代码,这次在做一些关于文件上传的东西。(PHP UPLOAD)小有收获项目是一个BT种子列表,用户有权限上传自己的种子,然后配合BT TRACK服务器把种子的信息写出来...2016-11-25
- 本文实例讲述了jQuery实现文件上传进度条效果的代码。分享给大家供大家参考。具体如下: 运行效果截图如下:具体代码如下:<!DOCTYPE html><html><head><meta charset="utf-8"><title>upload</title><link rel="stylesheet...2015-11-24
- 步骤:Window -> PHP -> Editor -> Templates,这里可以设置(增、删、改、导入等)管理你的模板。新建文件注释、函数注释、代码块等模板的实例新建模板,分别输入Name、Description、Patterna)文件注释Name: 3cfileDescriptio...2013-10-04
- 今天小编在这里就来给photoshop的这一款软件的使用者们来说下AI源文件转photoshop图像变模糊问题的解决教程,各位想知道具体解决方法的使用者们,那么下面就快来跟着小编...2016-09-14
- 这篇文章主要介绍了C++万能库头文件在vs中的安装步骤(图文),文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-02-23
- 本篇文章主要说明的是与php文件上传的相关配置的知识点。PHP文件上传功能配置主要涉及php.ini配置文件中的upload_tmp_dir、upload_max_filesize、post_max_size等选项,下面一一说明。打开php.ini配置文件找到File Upl...2015-10-21
ant design中upload组件上传大文件,显示进度条进度的实例
这篇文章主要介绍了ant design中upload组件上传大文件,显示进度条进度的实例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-10-29- 这篇文章主要介绍了C#使用StreamWriter写入文件的方法,涉及C#中StreamWriter类操作文件的相关技巧,需要的朋友可以参考下...2020-06-25
- 举一个案例:复制代码 代码如下:<?phpclass Downfile { function downserver($file_name){$file_path = "./img/".$file_name;//转码,文件名转为gb2312解决中文乱码$file_name = iconv("utf-8","gb2312",$file_name...2014-06-07
- 这篇文章主要介绍了C#路径,文件,目录及IO常见操作,较为详细的分析并汇总了C#关于路径,文件,目录及IO常见操作,具有一定参考借鉴价值,需要的朋友可以参考下...2020-06-25