php finding the directory name

kimwong99956

New Member
Messages
5
Reaction score
0
Points
0
I want my php program to allow the user to send emails with a pdf attachment. The user will choose the file, which they do by using the type="file" input tag. However while I can get the filename of the file I cant get the directory name, any ideas on how to do this?

thanx

Kim
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
If you mean the original directory name on the user's computer, you can't (at least not in most current browsers) -- and that's deliberate. It's part of the "sandbox" strategy of browser security. There should not be any way for a user's computer to be examined by simply visiting a web site. Obviously, the browser needs to know where the selected file lives in order to upload it, but it's not allowed to tell you that -- it'll give you the file name, but even if you use a separate text field to get the text content of the upload control, it won't give you the original file path. And you don't need it.
 

kimwong99956

New Member
Messages
5
Reaction score
0
Points
0
so how does my php program get the file and use it as an attachment to the php mail program?

Kim
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
If you're looking for the path to the file on the server, it's in the "tmp_name" entry for the file in $_FILES. Make sure you read "Handling file uploads" in the PHP docs to learn about file handling. The manual is your friend.
 

rimzikwebmaster70

New Member
Messages
5
Reaction score
0
Points
0
you have to upload first your file on the server after you can use realpath() or pathinfo to get the full path of your file
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
realpath isn't of much use, since the server sets the temporary name. pathinfo would be helpful if Kim wanted some part of the pathname give the full pathname, but it won't help to get the pathname itself.
 
Top