flex多文件上传工具
flex多文件上传工具(自用)
JAVA类
package com.shine.framework.flexUpload;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import com.shine.framework.config.FrameworkConfigFactory;
public class FileUploaded extends HttpServlet {
// 定义文件的上传路径
private String uploadPath = FrameworkConfigFactory.getConfig().getSysPath()
+ "\\upload\\";
// 限制文件的上传大小
private int maxPostSize = 100 * 1024 * 1024;
public FileUploaded() {
super();
}
public void destroy() {
super.destroy();
}
public void processRequest(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
System.out.println("Access !");
response.setContentType("text/html;charset=utf-8");
PrintWriter out = response.getWriter();
// 保存文件到服务器中
DiskFileItemFactory factory = new DiskFileItemFactory();
factory.setSizeThreshold(4096);
ServletFileUpload upload = new ServletFileUpload(factory);
upload.setSizeMax(maxPostSize);
try {
List fileItems = upload.parseRequest(request);
Iterator iter = fileItems.iterator();
while (iter.hasNext()) {
FileItem item = (FileItem) iter.next();
if (!item.isFormField()) {
String name = new String(item.getName().getBytes("gbk"),"utf-8");
System.out.println(name);
try {
item.write(new File(uploadPath + name));
// SaveFile s = new SaveFile();
// s.saveFile(name);
} catch (Exception e) {
e.printStackTrace()
相关文档:
Application组件样式属性
backgroundImage 背景图 使用Embed(source=" ");来应用
& ......
今天用Flex语言写了个检查非法字符,和数字的方法,共大家交流
稍微改一下就能用到.NET或Java语言中
public class CheckString
{
//判断用户是否输入非法字符
public static function CheckStr(strValue:String):Boolean
{
......
module 接口文件 PictureWindowInterface.as
package
{
public interface PictureWindowInterface
{
function setSelectIndex(index:int):void
}
}
moudule 文件 PictureWindow.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml ......
as 不允许overload...即对于同一个函数名不能有不同的参数列表和返回值
类中的geter 和 setter 与其他的方法一样,除了
1.get函数没有参数,并且必须有返回值,并且必须有get关键字
2.set函数必须有参数并且没有返回值,并且必须有set关键字
Java代码
public function get sampleProperty( ):Str ......
component就是一个AS class 或者是MXML component文件在manifest文件中映射的标签.分可视和不可视
可视化component包括Containers 和 UI controls
Containers(Appliction, Panel...)
UI controls(Button, Label)
可以通过3种方式设置component的属性
1.tag attributers
Java代码
<mx:Application xmln ......