大文件上传且带进度条的php解决方案

以下是用Pear::HTML_Progress实现大文件上传的例子

  • HTTP 1 – Upload files with your web browser to a web server. Single page (using frames).
  • HTTP 2 – Upload files with your web browser to a web server. Progress meter in a popup.
  • HTTP 3 – Mixed field Upload. Single page (using frames).
  • HTTP 4 – Upload files with your web browser to a web server and logs operations into a file.
  • FTP – Upload file on a remote ftp server that may be different than webserver.

    更多的HTML_Progress教程看这里:
    http://pear.laurent-laville.org/HTML_Progress/examples/

  • [@more@]

    PHPObject 1.44 released

    PHPObject 1.44早在这个月的15日就发布了,但是俺对这东东一直很欠感冒,因为它和AMFPHP一样对多字节的文字支持很差,可以说无法使用。

    今天看到超链接地址AMFPHP的中文使用办法 这篇文章受到了启发,在PHPObject中用同样的办法,果然也可以正常显示中文。

    测试时,这两个东东可以不加(也不能加):

    System.useCodepage=true;

    myFoo.utf8encode(false);

    下载超链接地址PHPObject 1.44

    php代码美化程序PHP_Beautifier试用手记

    在pear的rss列表上看到了PHP_Beautifier 0.1.1 beta发布,便下载回来试用:
    >>pear install PHP_Beautifier
    ………………………………………..

    顺利完成,看了下帮助,还带有命令行工具,方便:

    D:xamppphp>php_beautifier –help

    Usage: php_beautifier [options]
    and/or can be ‘-‘, which means stdin/stdout.
    you can use ? and * for batch processing
    can be a dir (ending with ‘/’ or a real dir)
    or a file (without ‘/’)
    multiple ins and one out = merge all files in one output
    Options:
    –input or -f input file – default: stdin
    –output or -o output dir or file – default: stdout
    –indent_tabs or -t indent with tabs
    –indent_spaces or -s indent with spaces – default
    –filters or -l Add filter(s)
    –directory_filters or -d Include dirs for filters
    –compress or -c Compress output
    –recursive or -r Search in subdir recursively
    –help or -? display help/usage (this message)

    Filter definition:
    –filters "Filter1(setting1=value1,setting2=’value2′) Filter2()"

    不过试用下来,处理的不是太完美,比如复杂点php代码美化后不整齐之类的,期待更好的版本出现 [@more@]

    PRADO v1.7发布

    PRADO v1.7发布。PRADO是什么?

    PRADO是在PHP5环境下的一个基于事件驱动和基于组件的WEB应用开发框架。使用PRADO开发WEB应用,你主要需要做的工作就是使用已有的组件(原文是"实例化已经定义好的组件",熟悉面向对象编程的开发者可能比较容易理解这句话),设置组件的属性,为控件组件的各种事件编写对应的处理函数,然后把这些组织成一个个的页面。这里是prodo 1.6的中文教程

    更新如下:

    Changes since v1.6
    =============
    – solved the incompatibility problem of Javascript used in validators
    – enhanced event handler binding (allow binding indirect child component events in template)
    – introduced parent-child relationship, the old one renamed to container-containee relationship
    – expression, statement tags with context being themselves
    – replaced TApplication::getInstance() with pradoGetApplication()
    – implemented handler concept in TApplication
    – added handler classes: TResourceParser, TResourceLocator, TRequest, TCacheManager, and TErrorHandler
    – defined new exception classes
    – TComponent added many properties
    – introduced module concept and implemented TModule
    – implemented application state handling
    – added AutoTrim to TTextBox
    – removed the application-level data encoding
    – instantiateTemplate will init properties
    – addChild will also load view state and synchronize life cycle of the new component
    – added blog example
    – added new components including TFormLabel, TValidatorGroup, TFileUpload, TCheckListBox, TListControl
    – added a tutorial for using validators

    PRADO v2.0RC发布

    PRADO v2.0RC发布,还不是稳定版本,但是可以尝试一下.更新如下:

    [@more@]

    – Added I18N, L10N support (with several relevant components)
    – Added TDataGrid, TTable, TDataList, TWizard, TRequiredListValidator controls
    – Implemented viewstate manager handler
    – Implemented enumerable property type
    – Changed the way of including a parameter file within another one
    – Added EncodeText property to controls with Text property
    – The parameter of TComponent::removeChild() is changed to component from ID
    – Control state synchronization is done in addBody() now (instead of addChild())
    – Control viewstate maintenance is now based on container-containee relationship
    – TComponent::addParsedObject() is now invoked when parsing an object
    – List control now renders values instead of indexes
    – Implemented TCollection class, Bodies property of TControl
    is now of type TCollection that allows insertion
    – Added Datalist, Datagrid and I18N examples
    – Implemented feature 1093392: Better package layout
    – Implemented feature 1094956: display spaces
    – Implemented feature 1102525: Module spec file
    – Fixed bug 1093843: TRepeater::getItemCount() returns wrong value
    – Fixed bug 1094219: TDateFormat patterns missing
    – Fixed bug 1093018: Translation table cache and php open tag
    – Fixed bug 1091966: Error handler doesn’t make allowances for @ operator
    – Fixed bug 1100512: Controls losing viewstate
    – Fixed bug 1103937: TListControl fatal error within TDataList
    – Fixed bug 1099808: TTextBox: Slashes won’t be stripped
    – Fixed visibility bug related with selection controls

    更好的将editplus与phpCodeBeautifier结合使用

    phpCodeBeautifier这款php代码美化工具已经很久不见更新,它的命令行版本似乎有些bug,不能正确的将php代码弄的很整齐。但是phpCodeBeautifier的GUI版本还是能够执行正确无误的,可惜无法直接在命令行模式下打开某个文件,想与editplus结合使用比较困难。

    但是注意到phpCodeBeautifier总是会打开上一次使用过的文件,打开phpCodeBeautifier.ini一看,LastFile=’******’不正是我们需要的东东么?

    于是俺写了如下批处理文件搞定这个问题:

    代码片段:

    
    set phpcb_path="F:Program FilesphpCB
    set phpcb_ini=%phpcb_path%phpCodeBeautifier.ini"
    echo [Settings]        >%phpcb_ini%
    echo LastFile=%1    >>%phpcb_ini%
    echo [MainForm]        >>%phpcb_ini%
    echo Left=-4        >>%phpcb_ini%
    echo Width=1032        >>%phpcb_ini%
    echo Top=-4        >>%phpcb_ini%
    echo Height=748        >>%phpcb_ini%
    echo [Options]        >>%phpcb_ini%
    echo FileFormat=0    >>%phpcb_ini%
    echo Settings=PEAR    >>%phpcb_ini%

    %phpcb_path%phpCodeBeautifier.exe

    在editplus的工具配置中调用以上批处理文件,参数为$(FilePath),一切搞定,可以用phpCodeBeautifier自动打开editplus当前编辑的文件:P

    利用xampp将apache和tomcat整合

    xampp可以将apache+php+mysql+phpmyadmin一次性自动安装完成,很适合快速搭建测试服务器.它也提供了tomcat的插件,可以很快的搭建jsp开发环境.

    以俺在winxp安装为例:
    1.在http://www.apachefriends.org/en/xampp-windows.html下载XAMPP,推荐下载EXE (7-zip) 打包的xampp,这个个头比较小,部署的时候也比较灵活.
    2.在同一页面下载tomcat插件,同样选择7-zip
    3.解压xampp的压缩包到你指定的目录,例如d:xampp
    4.运行setup_xampp.bat,至此,xampp安装完成
    5.解压tomcat插件到xampp目录,运行setup_java.bat即可将tomcat插件安装完毕

    现在一个php+jsp的快速开发环境已经搭建好了.

    附上tomcat的配置(详细信息见Readme):
    Tomcat Server Home = .xampptomcat
    Tomcat URL = http://localhost:8080
    Tomcat Doc Root = .xampptomcatwebapps

    JSP example Root = .xampptomcatwebappsjsp-examples
    JSP example URL = http://localhost/jsp-examples/

    Servlets example Root = .xampptomcatwebappsservlets-examples
    Servlets example URL = http://localhost/servlets-examples/

    Mod_jk java Root = .xampptomcatweppappsjava
    Mod_jk java URL = http://localhost/java/

    倘若你想建立更多的映射,那么就需要自行修改.xamppapacheconfworkers2.properties文件

    [@more@]

    等待pear投票的模板程序HTML_Template_Savant

    在zend.com上看到这个模板程序,咋一看结构代码都很像smarttemplate,但是细看处理方法却是截然不同,模板程序中都是直接使用的php代码,如下面这段常见的循环显示代码:

    < ?php foreach ($book as $key => $val): ?>
        
           < ?php echo $val[‘author’] ?>
           < ?php echo $val[‘title’] ?>
        
    < ?php endforeach; ?>

    我觉得用这种方式处理比较灵活,也还方便,而且并不需要生成cache之类的把戏,因为它本身已经是php程序了.加上方便的plugin和filter扩展,值得考虑,下面是这个模板的详细信息:

    http://pear.php.net/pepr/pepr-proposal-show.php?id=83