PHP-Image upload and retreival

Hey guys i m trying to upload an image and than retrieve it ,i want o get the image with respect to username therefore i cannot go for folder option as the retreival should be with respect to username so how can i upload an image inside my image column of the table?

Hi Jack

If I understood you correctly you are trying to add an image to a specific data table? If yes - you’ll need to add a column and to choose ‘File reference’ data type. Since then you can add images to this column by setting URI of an image location or choosing it from the File service (you can upload image to the ‘Files’ service).

Image will be retrieved when sending GET request for a particular user.

Regards Anton

Thanks for reply sir,I tried it which i guess is working but returned an error as max size reached of 500 symbols .How can i fix that?

If you are referencing the image from the File service - make the path shorter by moving the image location to the upper folders (the number of symbols in the path to the file should not extend 500), or rename the image (if it contains numerous symbols).

Another workaround is to switch data type to ‘text’ and insert the link of a file location to the necessary cell. But in this case you’ll have to write extra code for the image retrieval.

Regards Anton

Only problem with file refrencing for me is that would I have to do refrencing for every column manually , or is there a word around for that ,coz that would be really hectic.

Hi Jack,

As Anton said, you have two options:

  1. Keep your images’ URL length less than 500 and use the built-in File Integration. This way you won’t need to write much handling code.
  2. In case you really need longer names, you’ll need to just store a plain text URL in a TEXT column and handle file upload/download logic manually (though using Backendless File Service API of course).

Or maybe you mean something other by “referencing for every column manually”?

I meant once if I have uploaded my pic in media folder would i have to refer the column to that pic manually or is there some other way because there will be alot of images and i cant refer each one cell of table to one pic in files ,.
I hope I made my ques clear

There’s no possibility to link a file to an object via File Service API. You also cannot link an object to a folder.

What you could do is to try to automate this logic with some custom server code, it would still involve calling Data Service API and linking a file to some object though.