【发布时间】:2013-11-20 01:33:14
【问题描述】:
这是我在 Andorid 的基于 corodova 2.9.0 的应用程序中使用的代码。当我尝试上传照片时。应用程序崩溃了。
function uploadPhoto(imageURI)
{
Ext.Viewport.mask({ xtype: 'loadmask' });
var milliseconds = js_yyyy_mm_dd_hh_mm_ss();
var options = new FileUploadOptions();
options.fileKey="file";
options.chunkedMode=false; options.fileName=App.gvars.userid+milliseconds+imageURI.substr(imageURI.lastIndexOf('/')+1);
renamedfile=options.fileName;
options.mimeType="image/jpeg";
var params = new Object();
options.params = params;
var ft = new FileTransfer();
var url = "http://wish.brammies.com/itemimage/upload.php/";
ft.upload(imageURI, url, win, fail, options,true);
}
function win(r)
{
console.log("Code = " + r.responseCode);
console.log("Response = " + r.response);
console.log("Sent = " + r.bytesSent);
}
function fail(error)
{
console.log("An error has occurred: Code = " + error.code);
console.log("upload error source " + error.source);
console.log("upload error target " + error.target);
}
编辑 PHP代码
<?php
$folder = “/itemimage/”;
if (is_uploaded_file($_FILES['file']['tmp_name'])) {
if (move_uploaded_file($_FILES['file']['tmp_name'], $folder.$_FILES['file']['name'])) {
echo "File uploaded";
} else {
echo "File not moved to destination folder. Check permissions";
};
} else {
echo "File is not uploaded.";
};
//you get the following information for each file:
echo $_FILES['file']['name']."</br>"; //represents the name of file uploaded
echo $_FILES['file']['size']."</br>"; //represents the size of file uploaded
echo $_FILES['file']['type']."</br>"; //represents the mime type of file uploaded
echo $_FILES['file']['tmp_name']."</br>";
echo "fdggdr";
?>
Android运行版本4.1.4
请帮我解决问题。
【问题讨论】:
-
发布您的堆栈跟踪..
-
@kalyanpvs 这里是堆栈跟踪pastebin.com/UFyFHzZA
-
你的代码是原生的吗??
-
@kalyanpvs 其基于 phonegap 的应用程序。适用于 Android
-
您能否从您的日志猫中检查这一行:在线 /home/lamaire/public_html/ftp/itemimage/upload.php 中除以零
标签: android file-upload cordova-2.7.0