Page 1 of 2

Unable to upload image to custom collection

Posted: Sun Jun 08, 2014 8:26 pm
by Graeme6630509

Hi,

I am trying to upload an image to a custom collection.

I am using the input field with the type set to file.
In my create service i have mapped the file input field to a field in the db.
A button then calls the service.

When I click the button i am presented with the following error:

"invalid value for type object: C:/fakepath/image.jpg"

The code that is used to throw the exception is

var response = JSON.parse(jqXHR.responseText);
alert (response.description);

Does anyone know what theissue could be?

Thanks,
Graeme


Unable to upload image to custom collection

Posted: Sun Jun 08, 2014 8:37 pm
by Illya Stepanov

Hello -

Are you following this tutorial: http://devcenter.appery.io/tutorials/... -?
Can you show your service settings tab, and request/response tabs with mapping?


Unable to upload image to custom collection

Posted: Sun Jun 08, 2014 8:44 pm
by Graeme6630509

I was following it up until the final section. I did not want it uploaded to the files data collection so i deviated slightly. Do files have to be uploaded to the files data collection?


Unable to upload image to custom collection

Posted: Sun Jun 08, 2014 8:58 pm
by Graeme6630509

When I try to upload the file to another collection using the method in the example above I get the following in the javascript console:

This data source not be supported in the method of upload multiple files.

Does this mean files can only be uploaded to the files data collection?


Unable to upload image to custom collection

Posted: Mon Jun 09, 2014 1:40 am
by Michael Jordan

In the database, did you implement a GET request, and set data type to JSON, and it looks like your structure is jQuery based not JavaScript, maybe try this formula

var json = '{"example": true,"example": }' ,
obj = JSON.parse(json);

alert(obj.example);


Unable to upload image to custom collection

Posted: Tue Jun 10, 2014 2:16 pm
by Evgene Karachevtsev

Hello Michael,

Sotty for delay. You can upload files only into predefined collection "Files"


Unable to upload image to custom collection

Posted: Sun Aug 31, 2014 4:30 pm
by Graeme6630509

Thanks Eugene,

How would you then go about associating this data with data in another collection? e.g. a fileDetails collection?


Unable to upload image to custom collection

Posted: Mon Sep 01, 2014 4:55 pm
by Evgene Karachevtsev

Hello Graeme,

You may use a column of type file. You may link by the actual file name (column "File Name" in the collection of Files).


Unable to upload image to custom collection

Posted: Tue Sep 30, 2014 7:35 pm
by Graeme6630509

Thanks Evgene,

How do I return the file name using the uploadMultipleFilesHelper(uploadService, Apperyio('')); javascript?


Unable to upload image to custom collection

Posted: Wed Oct 01, 2014 2:23 am
by Yurii Orishchuk

Hi Graeme,

It's not fully clear what you want.

But you if you goal to get selected file name here is code:

pre

//Note: you should replace "file_input" with your file input component name.
var files = Apperyio('file_input')[0].files;
for(var i = 0; i < files&#46;length; i++)
alert(files&#46;name);

&#47;&#47;Note: you should replace "file_input" with your file input component name&#46;
uploadMultipleFilesHelperWithCustomName(uploadService, Apperyio('file_input'));

/pre

Regards.