function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
alliswellalliswell 

File..path

Hi All,

 

Say there's a custom button called 'File Info' in a custom object A.

Once clicked, it opens up a browser window.

From there, a user will choose a file.

When user clicks 'Select' button in that browser window, a new record will be created with the File Name and File Location in the custom object A. And the file is stored in a local network drive.

 

I don't think it is possible at all in Salesforce. But I would really appreciate your insights and experiences. 

 

We can definitely create a button to open up a browser window and select the file...

But once the user selects the file, how can we ever display it's path..in local network drive??

 

Merci Beaucoup 

 

alliswellalliswell

This link here has a solution to fetch file and file path using Java...

http://stackoverflow.com/questions/7991294/fetching-file-and-path-from-network-using-java

But I have no clue if this could be implemented in salesforce to actually create a record consisting of file name and file path in two different fields...

 

Any thoughts dear people?

ryanjuptonryanjupton

alliswell, you can't create a local file directly with just Visualforce and Apex. You would have to have a web service on you end that we can call out to that would create the file locally.

alliswellalliswell

Thanks for the insights Ryan :)

 

But the requirements I have is:

-  Let the user browse and select the file(the file is stored in local network drive) through browser window.

- Populate the path and name of the file.(Not the actual file itself)

 

Any other insights??

 

Thanks for your time!!!

ryanjuptonryanjupton
This talks about uploading a file from the local file system to Salesforce.
You could follow it right up to the point of actually assigning the file I
believe. If I understand what you are trying to do correctly:
http://developer.force.com/cookbook/recipe/uploading-a-document-using-visualforce-and-a-custom-controller
alliswellalliswell

Ryan,

 

Thank you once again for your time! However, I still need some guidance...

That was pretty awesome. Thanks for the link :)

 

It does allow me to browse local network( e.g. \\network\salesforce.\documents\)

 

However, once the user selects the file, how can we populate the PATH(For example-  \\network\salesforce\documents\file.doc) of the file?

 

Say, I don't need to upload the file itself...but all I need by clicking a file in local network, is it's name and path and populate these info as a record.

 

Can we do it?

 

Thank you!!

Avidev9Avidev9
I guess you cant get the File path using VF or APEX. To do this you have to USE flex in your page that will grab the file and do the needful!

For further details about integrating VF with FLEX have a look here http://blogs.developerforce.com/developer-relations/2009/09/integrating_flex_into_visualforce_pages.html
ryanjuptonryanjupton

Here's the code that will get you the file name and store it to an object's field. For this example I've created a custom object called DocInfo with a custom field called DocName. You have to look here http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_inputFile.htm on your own to see if you can use the foundation I've supplied to figure out a way to get the path. I'm not sure you can but perhaps you'll figure it out.

 

Controller:

public with sharing class UploadFileController {
	public Document doc{set; get;}

	public UploadFileController() {
    	doc = new Document();
    }
    
    public PageReference storeFileInfo(){
        DocInfo__c dInfo = new DocInfo__c();
        dInfo.DocName__c = doc.name;
        insert dInfo;
        return null;
    }
}

 

Page:

<apex:page controller="UploadFileController" showHeader="true" sidebar="true">
	<apex:form id="FileForm">
		<apex:inputFile value="{!doc.body}" filename="{! doc.name}"></apex:inputFile>
		<apex:commandButton action="{!storeFileInfo}" value="Store File Info"/>
    </apex:form>
</apex:page>

 

alliswellalliswell

Thank you Avidev9! Will certainly use the info on my way to the solution!

alliswellalliswell

Thank you for your time and guidance Ryan!

Will start working towards writing a solution soon. Hopefully will be back with some workarounds :)

 

Thank you once again!

ryanjuptonryanjupton

Awesome. Please do the community a favor and post back what you ended up doing. It's great for future reference.

alliswellalliswell

So far it doesn't look feasible to do it through Apex/VF... 

<apex:inputfile> has fileName and fileSize attribute but not filePath

Asked other experts on their opinion...and seems like it is not possible/feasible get file path..

 

@sfdcfox kindly provided me some direction....using Java to build an applet and integrate onto the Salesforce...

 

There are methods in Java like getpath(), getabsolutepath() and I was thinking if I can look into the source code and may be replicate the process..but the concept got really complicated before I started....

 

Any thoughts Ryan?

 

Thanks!!