Has been resolved.
I forget to add setting of ExternalHosts.
to add new item (value = *) to PhoneGap.plist - ExternalHosts
On 2月24日, 午前9:21, ta_ni_ <kazuyat7...@gmail.com>
wrote:> Hi all
> Any advice in how to transfer image data from phone gap to rails?
>
> I try to write small code,but that can not transfer image data.
> below is samall corde(server address:192.168.100.242:3000
> controller:photos action:up)
>
> /////////////////////////////
> rails :routes.rb//////////////////////////////
> Store::Application.routes.draw do
>
> get "photos/up"
>
> //////////////////////////////rails
> photos_controller.rb//////////////////////////////
> class PhotosController < ApplicationController
> def up
> p "-------"
> p params
> end
> end
>
> //////////////////////////////phonegap
> index.html//////////////////////////////
>
> (function($) {
> document.addEventListener("deviceready", function() {
>
> $("#camera").click(function(){
> navigator.camera.getPicture(
> uploadPhoto
> , function(error) {
> alert("camera error");
> }, {quality: 50, destinationType:
> Camera.DestinationType.FILE_URI});
> });
>
> });
> function uploadPhoto(imageURI) {
> $("#image").attr("src", imageURI);
> var options = new FileUploadOptions();
> options.chunkedMode = false;
> options.fileKey="file";
>
options.fileName=imageURI.substr(imageURI.lastIndexOf(''/'')
> +1);
> options.mimeType="image/jpeg";
>
> var params = new Object();
> params.value1 = "test";
> params.value2 = "param";
>
> options.params = params;
>
> var ft = new FileTransfer();
> ft.upload(imageURI,
"http://192.168.100.242:3000/photos/up",
> win, fail, options);
> }
>
> function win(r) {
> console.log("Code = " + r.responseCode);
> console.log("Response = " + r.response);
> console.log("Sent = " + r.bytesSent);
> }
>
> function fail(error) {
> alert("An error has occurred: Code = " = error.code);
> console.log("upload error source " + error.source);
> console.log("upload error target " + error.target);
> }
> })(jQuery);
>
> Regards
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.