Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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="">?

share|improve this question

1 Answer 1

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

share|improve this answer
    
yes i tried it before apex:inputfile do not support it. It throws an error "<apex:inputFile> does not support pass-through attributes" –  Anu Jul 14 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') –  Michael Welburn Jul 14 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 Jul 15 at 6:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.