有很多人提出與此問題有關的問題,但沒有一個足以解決我的問題。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例子,它將使用上面的上傳代碼,只是對相機圖像做些什麼。
一旦我可以得到一個工作示例,我可以準確地分解正在發生的事情並開始學習過程。
另外,如果有人可以提供一個工作應用程序..與應用程序和服務器端代碼作爲教程使用,我很高興做相關的研究。
許多人提前感謝任何時候人們給這個。當我能夠完成這個任務時,我正在思考自己的情況,並讓自己陷入困境。
我可以看到您的發佈方法嗎? –