Graeme6630509
Posts: 0
Joined: Sun Feb 02, 2014 5:26 pm

Unable to upload image to custom collection

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

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Unable to upload image to custom collection

Hello -

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

Graeme6630509
Posts: 0
Joined: Sun Feb 02, 2014 5:26 pm

Unable to upload image to custom collection

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?

Graeme6630509
Posts: 0
Joined: Sun Feb 02, 2014 5:26 pm

Unable to upload image to custom collection

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?

Michael Jordan
Posts: 0
Joined: Fri May 02, 2014 9:09 pm

Unable to upload image to custom collection

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);

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Unable to upload image to custom collection

Hello Michael,

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

Graeme6630509
Posts: 0
Joined: Sun Feb 02, 2014 5:26 pm

Unable to upload image to custom collection

Thanks Eugene,

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

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Unable to upload image to custom collection

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).

Graeme6630509
Posts: 0
Joined: Sun Feb 02, 2014 5:26 pm

Unable to upload image to custom collection

Thanks Evgene,

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

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Unable to upload image to custom collection

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.

Return to “Issues”