Does anyone know how to use a Browse for a file button in PHP. Basically what I want to do is have a browse button that you can browse for a file with. I have the browse button code like this. <FORM name = "fileSplit" method = "post"> Insert path: <INPUT NAME="userfile" TYPE="file"> <INPUT TYPE="submit" name = "submit" VALUE="Split File"></FORM>
Now I have read some things about ENCTYPE = multipart/form-data. I don't really need to read the file however I just want to get the path. What I mean is say the file they uploaded was c:\some folder\file.txt on their local machine I would like to get that path. This is just for our intranet so these paths I can pass in directly to work with the file. Also, would there be any way to get the full path if they enter a mapped drive. What I mean is say a machine is named machine01. Now on their machine that drive may be X:\some folder and on my machine that drive may be mapped as M:\some folder. I would like to get that as \\machine01\some folder. Any help on how to do this, I'm rather lost so any suggestions would be great. Thanks,
I have another text box that allows them to input it manually and the user can copy and paste the path that the browse button fills in the text box, I just wanted to make it so the user would not have to copy and paste. If there is no way around it that is ok. Thanks,
Msg#: 3699881 posted 12:14 am on Jul 17, 2008 (gmt 0)
Yes I know, I just didn't want to have to mess with JS because I hate it and it is not powerful enough to do what I want. I would end up with a mess of PHP and JS or setting a header in PHP to output in JS and I don't want to deal with that headache. Thanks,
Msg#: 3699881 posted 4:16 am on Jul 17, 2008 (gmt 0)
Alright ran a quick test. Calling the value of the file element in a form gives you the path of the file. This only works in Internet Explorer, however; I tested it on Opera and Firefox, as well, and you only get the filename not the whole path. In any case, since this is for your intranet, I don't think it would be too much to ask if they used IE to use it, although there might be a more universal solution, I just don't know of it. But to get the filename in IE, it looks something like this: var file_path = document.getElementById("browse").value
Yea I may break down and use JS but try to figure out a way to get it to work. As far as the IE thing goes, everyone in the office uses IE. I'm the only person who uses FF (because it is simply much more user friendly). Usually, I have the problem of things working or looking fine in FF and Opera, but not working or showing correctly in IE so this will be a first. Thanks for all of your help.