Hi,
Is it possible to make a html form which prompts for a directory (and not for a file) ?
If it's not, how do I get, in a php script, the path of a file whose name I've transmitted with an ' input type="file" ' tag ?
(I want to make a script which lists all the files in a user chosen directory)
TIA
question about directories
Moderator: General Moderators
Not sure what you are talking about but you might want to check one of these:
http://us2.php.net/manual/nl/function.scandir.php
http://us2.php.net/manual/nl/function.glob.php
Thanks for your answer,
but I don't want to write the path in my script (something like $path = 'tmp/dir')
I would like the user to choose a path (maybe only possible by choosing a file in that path) in a HTML form, and I would like to know the php function wich gives me the path the user chose (or the path of the file he chose).
So, I was planning to make a form with an 'input type = "file"' tag, so the user would have to chose a file.
Then I would like my php script to give back the path of the file he chose (if he chose the file "c:\text\document.txt", I would like to know how to get "c:\text\" in a variable)
TIA
but I don't want to write the path in my script (something like $path = 'tmp/dir')
I would like the user to choose a path (maybe only possible by choosing a file in that path) in a HTML form, and I would like to know the php function wich gives me the path the user chose (or the path of the file he chose).
So, I was planning to make a form with an 'input type = "file"' tag, so the user would have to chose a file.
Then I would like my php script to give back the path of the file he chose (if he chose the file "c:\text\document.txt", I would like to know how to get "c:\text\" in a variable)
TIA
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
You might need to use some javascript that takes whatever is in the filename form field and copies it to a hidden text field. Then, when the form is posted, upload the file from the filename field but use the text in the text box field for the path. This is not a best way to do it, but it should give you what you want.