+ Start a Discussion

How to work with dynamic images in visualforce?

I am wanting to have a custom object with a url field.  The url will reference a static image.
My question is how can I implement an edit facility on my custom object so that the images can be added/edited?
My custom object works fine displaying images that I manually uploaded into static resources, where I then manually pasted the url into the records.  But how can I make this work automatically?
I can't find anything telling me how to upload files through code.....
BTW, Jasons Employee App is roughly what I am trying to do http://wiki.apexdevnet.com/index.php/Visualforce_Employee_App
However this sample app does not have the edit function.  Maybe its just not shown in the public demo?? 


Message Edited by GerhardNewman2 on 05-29-2008 06:05 AM
Ron HessRon Hess
yes, that's a read only demo.

you would like to edit the details, and upload a new picture?
Yes, exactly!
i had the same question a few months ago. i couldn't find any way to do a "file upload" field from visualforce:  a field that prompts the user to pick a file from their local filesystem and presents a blob to the visualforce controller. (i posted a message on the visualforce board asking about it).

since i didn't see a way to do it in vf, i wrote a php page and embedded it in my vf page using an iframe tag. the iframe url included the serverUrl, sessionId, and the id of the current record i was editing in vf so that my php page could call back into sfdc and write the binary value (the uploaded image) into the relevant sobject. that worked well.

(demo) jason

Thanks Jason. We currently don't have a component that supports file upload, but it is definitely on the roadmap.