You need to sign in to do that
Don't have an account?
VisualForce Javascript get Blob object from inputFile
I have an inputFile field that the user can upload a file into (in this case, we are only using CSV files)
In the Javascript, I try to reference the uploaded CSV:
How can I make csvfile be the Blob uploaded?
<apex:inputFile id="csvfield" value="" />
In the Javascript, I try to reference the uploaded CSV:
var csvfile = document.getElementById('{!$Component.csvform:out:csvfield}').value;However, I'm not able to work with it because I'm not getting a Blob, but a String.
How can I make csvfile be the Blob uploaded?
for upload csv file into vf page follow given steps-
Step1-
Download the template from the DEMO URL above. Save the file in your desktop. Upload the file into Static Resources with the name "AccountUploadTemplate".
link is http://forcetreedemos-developer-edition.ap1.force.com/forcetreedemos/resource/1327282481000/wippipelinemgr__AccountUploadTemplate. (http://forcetreedemos-developer-edition.ap1.force.com/forcetreedemos/resource/1327282481000/wippipelinemgr__AccountUploadTemplate)
Step 2.
Create an Apex Class named "FileUploader". Paste the code below and save it. Step 3.
Create a Visualforce Page named "UploadAccounts". Paste the code below and save it.
Thanks
Rupal.
I understand what you explained above and have done this already, but I am JS Remoting the process as otherwise my view state blows up. I have the controller and Javascript Remoting set up, I just need to pick up the Blob from the inputFile field via JavaScript and send it to my Controller method via JS Remoting.
When I try to get the Blob thru Javascript with document.getElementById('{!$Component.csvform:out:csvfield}') or document.getElementById('{!$Component.csvform:out:csvfield}').value I just get a String, not the Blob.
The given example workes good for the header values or fields which statically defined but if we have a custom object and using the object we are geeting the header name and uploading the csv file how we can achive this. please help me out for this senario.
thanks in advance.
priya