---
title: "sencha touche 上传图片  \u3000"
author: "junjun16818"
date: "2011-02-25T17:27:25Z"
tags: ["Ajax", "jQuery", "json"]
categories: ["Web前端"]
slug: "sencha-touche"
draft: false
lastmod: "2011-02-25T17:27:25Z"
id: 930271
url: "https://junjun16818.iteye.com/blog/930271"
---

写了2天终于写出来 touche上传的解决办法了  

下载jquery 上传插件

ajaxfileupload.js  并引入

 

下面是上传控件的写法 

 

 

```
item[
{
            	xtype: 'textfield',
            	name: 'filename',
            	id:'files',
            	inputType : "file",
            	label: '头像',
            	placeHolder: '请输入图片网页路径URL',
            	autoCapitalize : true,
                required: true,
                useClearIcon: true
}]

```

 

       jquery ajax上传的方法

```
 function ajaxuploadImg(name)
{
	 alert(1);
	   $("#loading")
	    .ajaxStart(function(){
         $(this).show();
     })
     .ajaxComplete(function(){
         $(this).hide();
     });
	   $.ajaxFileUpload
    (
        {
            url:'uploadFile!uploadTest.action?testName='+name, 
            secureuri:false,
            fileElementId:'files',
            dataType: 'json',
        }
    )
}
```

  点击上传 触发事件

```
ajaxuploadImg("上传后的图片名");
```

 

　后台定义一个　fileName　和testName变量即可