6

I have create a VF page which is accessible on mobile through which I can take pic and attach it to the selected record. For this I have created a input tag in html

<input type="file" accept="image/*" capture="camera" id="photo" name="photo" filename="{!fileName}" value="{!photoUpload}"/> 

By using this code I am able to access my mobile cam but not able to sent the filename value to the controller for attachment but when I use Visualforce:

<apex:inputFile accept="txt" filename="{!fileName}" contentType="{!contentType}" value="{!photoUpload}" />

I am not able to use the capture="camera" attribute but able to attach the image to the record.

How can I use the capture="camera" in apex:inputFile or is there any way to pass the value of the selected file to the controller from <input type="">?

1 Answer 1

5

Have you tried using the html- prefix on your Visualforce component attributes?

<apex:inputFile html-capture="camera" accept="txt" filename="{!fileName}" contentType="{!contentType}" value="{!photoUpload}" /></apex:form>

https://www.salesforce.com/us/developer/docs/pages/Content/pages_html_features_pass_through_attributes.htm

3
  • yes i tried it before apex:inputfile do not support it. It throws an error "<apex:inputFile> does not support pass-through attributes"
    – Anu
    Commented Jul 14, 2014 at 17:49
  • If that is the case, you could probably use something like jQuery to set that attribute on page load. Give it a specific class and do jQuery('.myclass').attr('capture', 'camera') Commented Jul 14, 2014 at 18:05
  • yes, this work. But there is a issue that it only works with ios(iPhone) it doesn't work on Android. For iPhone it ask for whether need to take pic or choose form gallery but got android it only have option to select from gallery. Do u have any idea over this i am working first time with salesforce1 does i am missing out anything.
    – Anu
    Commented Jul 15, 2014 at 6:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .