有很多人提出与此问题有关的问题,但没有一个足以解决我的问题。Phonegap黑莓照片上传服务器php脚本
我已经创建了一个完全正常工作的HTML5智能手机应用程序,基于phonegap .. ..不寒而栗...黑莓利用服务器端PHP脚本将数据很好地发送到远程MYSQL服务器。
但是我想给出选择也上传照片,因为这是伤害预防,危害需要拍摄。这是一个非商业产品,它是现代智能手机技术的一个工作示例,并演示如何将一个应用程序轻松移植到各种智能手机上。黑莓手机是常见的手机,并且必须是最好的例子。
我不能为了爱和金钱找到一个应用程序和一个php服务器端脚本的任何工作示例在一起。
我从CORDOVA示例文件中提取的示例拍摄了一张照片,我可以在我的应用程序中看到生成的缩略图,而且这一点都很可爱(基于您在下面看到的所有代码),但我不知道我需要为我的upload.php编程来做些事情。我所尝试的一切都失败,错误代码为3和1 ..
这是Web应用程序的重要代码。
HTML
<h3>navigator.camera</h3>
<input type="button" value="Get Photo (Data)" onclick="capturePhoto();return false;" />
<input type="button" value="Get Photo (URI)" onclick="capturePhotoURI();return false;" />
<img style="display:none;width:120px;height:120px;" id="cameraImage" src="" />
<p id="uploadProgress"></p>
<input style="display:none;" id="uploadButton" type="button" value="Upload" onclick="uploadImage();return false;" />
JAVASCRIPT
function capturePhotoURI() {
navigator.camera.getPicture(onCapturePhotoURISuccess, fail,
{ destinationType: Camera.DestinationType.FILE_URI, quality: 50 });
}
function onCapturePhotoURISuccess(imageURI) {
if (imageURI != null) {
var smallImage = document.getElementById('cameraImage');
var uploadButton = document.getElementById('uploadButton');
// Unhide image elements
smallImage.style.display = 'block';
uploadButton.style.display = 'block';
// Show the captured photo
// The inline CSS rules are used to resize the image
smallImage.src = imageURI;
}
}
function uploadImage() {
var smallImage = document.getElementById('cameraImage');
if (smallImage.src && smallImage.src !== "") {
var f = new FileTransfer();
f.upload(
// file path
smallImage.src,
// server URL - update to your own, and don't forget to
// include your domain in an access element in config.xml
"http://192.168.1.91/upload.php",
// success callback
function(result) {
document.getElementById('uploadProgress').innerHTML =
result.bytesSent + ' bytes sent';
alert(result.responseCode + ": " + result.response);
},
// error callback
function(error) {
alert('error uploading file: ' + error.code);
},
// options
{ fileName: 'myImage.jpg',
params: { 'username':'jtyberg' }
});
}
}
上述服务器ID是正确的(这是我自己开发服务器的正确翻译,所以我没有使用本地主机,因为我需要这是准确)。除了服务器IP之外,您看到的所有东西都是vanilla,箱子外,从phonegap不变的工作示例。这款手机是一个相同的192网络和defintaly尝试运行任何upload.php的我尝试
基本上,我想利用这个文件,并使用upload.php的文件,将其移动到
的http:// 192.168 .1.91 /伤害/ sample_images/xxxx.jpg(间距http用作不知道如何阻止它连接)
我已经检查的权利,他们都是OK的,我config.html有允许所有域
可以人请把我的痛苦放到我身上,并给我一个upload.php例子,它将使用上面的上传代码,只是对相机图像做些什么。
一旦我可以得到一个工作示例,我可以准确地分解正在发生的事情并开始学习过程。
另外,如果有人可以提供一个工作应用程序..与应用程序和服务器端代码作为教程使用,我很高兴做相关的研究。
许多人提前感谢任何时候人们给这个。当我能够完成这个任务时,我正在思考自己的情况,并让自己陷入困境。
我可以看到您的发布方法吗? –