使用HTML5上传照片

时间:2013-08-06 12:01:31

标签: html5 jquery-mobile post base64 image-uploading

我正在开发基于HTML5和jQuery的iPad应用程序。我需要将图像上传到服务器。 服务器网址为https://myserver.myclient/myproject/uploadphotos

我需要有如下的请求数据 {   “FileName”:“abc.jpg”,   “FileDescription”:“文件描述”,   “FileData”:“Base64编码字符串”,   “LibraryId”:“libraryId”,   “FileTitle”:“第一个文件” }

文件上传部分的HTML代码部分如下,

<tr>
          <td class="ui-table-priority-1">
            <div class="ui-input-text ui-shadow-inset ui-corner-all ui-btn-shadow ui-body-c ui-input-has-clear">
                <input type="file" name="file" id="file" value="" data-clear-btn="true" class="ui-input-text ui-body-c">
                <a href="#" class="ui-input-clear ui-btn ui-btn-up-c ui-shadow ui-btn-corner-all ui-fullsize ui-btn-icon-notext ui-input-clear-hidden" title="clear text" data-corners="true" data-shadow="true" data-iconshadow="true" data-wrapperels="span" data-icon="delete" data-iconpos="notext" data-theme="c" data-mini="false"><span class="ui-btn-inner"><span class="ui-btn-text">clear text</span><span class="ui-icon ui-icon-delete ui-icon-shadow">&nbsp;</span></span>
                </a>
            </div>
          </td>
          <td class="ui-table-priority-2">
          </td>
        </tr>

我能够获得像filename,filedescription,filetitle和library id这样的参数。 我需要获取“文件数据”的base64Encoded字符串以及将其发布到服务器的代码。

请帮我上传照片。我正在推荐的项目仅使用HTML5,jQuery Mobile和JavaScript。

提前致谢,

阿宾

1 个答案:

答案 0 :(得分:0)

要使用HTML5与网络摄像头互动,您可以查看以下文章: http://www.codeproject.com/Articles/463874/Webcam-and-Annotation-With-HTML5

对于base64编码,请检查以下线程: How can you encode a string to Base64 in JavaScript?

相关问题