Jump to content

[SOLVED] How to get file path and file name


sbrinley

Recommended Posts

I'm in charge of building our company intranet system. In that system I'm trying to build a simple interface for site administrators to link file paths and names to the site without knowing the actual path of the file but to select the path in something similar like uploading a file through a HTML form. Also while doing this please assume these things:

 

  • All files that will be linked will be hosted on the company file server.
  • All shared server folders have standardized drive letters. For example the purchasing drive for all users would be P:
  • a sample link path might be K:/HR/orgchart.ppt
  • All permissions would be handled through Active Directory outside of PHP
  • this site would be for internal use only. No one from the outside would be able to access the site unless through a VPN connection.

 

Basically all i need is a way for users to select a file through a file explorer or browser and store it as a variable(s). I can handle the rest form there.

 

If you need more information please let me know!!

 

If someone could help I would appreciate it!

 

Link to comment
Share on other sites

I think I have narrowed down what I'm exactly looking for.

 

If I can grab the users URI from the form posting. I tired looking at the posting array but nothing is shown except the following

 

Array ( [userfile] => Array ( [name] => SNC00003.JPG [type] => image/jpeg [tmp_name] => C:\WINDOWS\Temp\php97.tmp [error] => 0 => 97817 ) )

 

 

 

Link to comment
Share on other sites

How is that nothing? What are you looking for? Sorry if I didn't understand.

It's ok. Half the battle in any problem is asking the question the right way to get the answer. Sometimes I feel like I should have interpreter so people can understand me... anyways here's another try

 

Here is a sample upload screen

upload.jpg

 

what I am looking for is when this form is submitted is a way to grab the path in the form. I want to take the C:\Downloads\test.txt or whatever the value happens to be and post it to a string so I can then use it later.

 

the goal is the user doesn't have to know the exact path they can use the browse button to find the file. 

 

Link to comment
Share on other sites

True. However I don't actually want the users to upload the file I want the path of the file they are choosing.

 

The point is to allow the user to link files on a page in an internal network. An example would be:

 

User A wants to link the company org chart to everyone. They log onto the internal internet page, choose the file at this location for example z:/hr/orgchart.ppt by browsing, they submit the file.

 

User B goes to the page and clicks the link to view. instead of going to a directory on the web server as if someone uploaded the file they are pointed to z:/hr/orgchart.ppt

 

The point of this is to eliminate users from putting files on both the file server and web server.

 

Maybe I'm going about this in the wrong way but basically I just need users to select a path of a file by browsing then have that path posted as a link on a page.

 

 

Link to comment
Share on other sites

Okay that can't work. You'll need a shared server for that and even then, User A would have to upload the file to the shared server so User B can access it from there. If you were to just link to a file on my computer, that's a security flaw. Forget about if my computer if not online. People can cause havoc to my computer if they can just have access to my files like that.

Link to comment
Share on other sites

Yes sir you are completely correct.

 

However this is a corp network. Users would be pointing files to a mapped network drive that is shared and security is provided by active directory. PHP is simply providing the link to that directory or file.

 

User A might know where the file is located but they don't know the full path and or file extension on the file. My end goal is to allow users to link their own files instead of manually linking them or changing things every time a file version changes or they wish to add more files.

 

If PHP isn't a good solution do you happen to have an idea on what language to look? I though about java possibly but I have zero knowledge of java :(

Link to comment
Share on other sites

Well corp or no corp, I don't think there is a way to get that path value. Similar issues to this have came up before and to this date, there hasn't been any solutions. But I think Daniel0 said it's possible with Java, not JavaScript or any web-based language.

Link to comment
Share on other sites

Thanks for the help I appreciate you looking at this. None the less I've submitted the same question in the Java section maybe someone might have an idea. If I happen to find a solution I'll be sure to post in case someone else is looking for something similar.

Link to comment
Share on other sites

Here's a little update on what I've found so far

 

This code

 

<form>

<textarea name='abc' rows=30 cols=50></textarea>

<input type=file onchange="this.form.abc.value+=';' + this.value; return

true;" multiple>

</form>

 

 

In firefox 3 I will get the name of the file just like the $_FILES however with IE8 I get this on the left side

 

;C:\fakepath\SNC00102.jpg

 

here's a screen shot.

upload2.jpg

 

The actually path of the file selected is c:\downloads\SNC00102.jpg as you can see from the screen shot...

Link to comment
Share on other sites

I decided to move on to the next part of the project assuming I could get this to work which is linking the files to a path. It seems IE7, IE8 and firefox have local access links disabled.

 

I have found a few solutions to enable them but this opens a huge security risk and is somewhat time consuming.

 

I'm going to mark this question as solved since there isn't a solution / even if this works it can't go anywhere.

 

Thanks for your help.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.