Jump to content


Photo

File upload path


  • Please log in to reply
4 replies to this topic

#1 JRS

JRS
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts

Posted 25 April 2006 - 03:44 AM

Hello,
I'm writing a mail script with attachment. I have a test mode, where a user can setup the mail and do mass mailing. One of the setup is for the user to select a file attach to the email and do test mailing. If this ok, do the mass mailing.

I would like to get the full path and filename of the attachment. However, the $_FILES global variable will only provide the filename and temporary path - appears to be in Windows\temp directory.

The real path is c:\email\testfile.txt
I can only get name: testfile.txt and path\tempfile would be windows\temp\php5.txt

So after the test mailing - user has to browse for the file attachment again - I'm not able to set the value because I do not have the path available to me. Is this a security issue? Is there a way for me to get the real path of the file attachment?

Thanks in advance
JRS


#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 25 April 2006 - 04:05 AM

Remember, PHP runs on the server which may or may not be the same machine the user is on. Why would you want to know the original location of the attachment. The recipient doesn't care. He just wants the contents of the file. The path you mentioned would only be true if you are running the server on Windows and took the default path for the /tmp directory. And the sender already knows where the original was.

Ken

#3 JRS

JRS
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts

Posted 25 April 2006 - 04:28 AM

[!--quoteo(post=368274:date=Apr 25 2006, 12:05 AM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Apr 25 2006, 12:05 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Remember, PHP runs on the server which may or may not be the same machine the user is on. Why would you want to know the original location of the attachment. The recipient doesn't care. He just wants the contents of the file. The path you mentioned would only be true if you are running the server on Windows and took the default path for the /tmp directory. And the sender already knows where the original was.
Ken
[/quote]

Ken,
Thanks for the reply, the reason I want the path is to make the life of the sender easier. Now, after the sender sends the test email - the file attachment input window is reset to blank. So if the sender wants to send the email to all the people on his/her list - the sender has to browse to the file again to attach it. However, if I knew where it was - then I can set the value of the <input type=file ...> field.

My concern is person would send the test email - find it ok, decides ok let do the mass mailing and forget to attach the file - since they already did it once. (Plus I am also able to repopulate all other fields on the form - except for the file attachment)

Thanks
JRS


#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 25 April 2006 - 04:56 AM

The only way you can save the path on the client side is with Javascript,, I also think that Javascript can prefill the browse box. I know PHP can't.

What you may have to do is to use AJAX to invoke a PHP routine, passing it the client side path to store in a session variable, then the next time you put up the form, your PHP script would get the value out of the session variable and write the Javascript code that would pre-fill the field.

I don't know whether this will work, since I just thought of it and haven't had time to write any code, let alone test it.

Ken

#5 JRS

JRS
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts

Posted 26 April 2006 - 02:36 AM

[!--quoteo(post=368283:date=Apr 25 2006, 12:56 AM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Apr 25 2006, 12:56 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
The only way you can save the path on the client side is with Javascript,, I also think that Javascript can prefill the browse box. I know PHP can't.

What you may have to do is to use AJAX to invoke a PHP routine, passing it the client side path to store in a session variable, then the next time you put up the form, your PHP script would get the value out of the session variable and write the Javascript code that would pre-fill the field.

I don't know whether this will work, since I just thought of it and haven't had time to write any code, let alone test it.

Ken
[/quote]
Ken,
Thanks - I will give it a shot.
JRS





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users