JRS Posted April 25, 2006 Share Posted April 25, 2006 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.txtI can only get name: testfile.txt and path\tempfile would be windows\temp\php5.txtSo 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 advanceJRS Quote Link to comment https://forums.phpfreaks.com/topic/8331-file-upload-path/ Share on other sites More sharing options...
kenrbnsn Posted April 25, 2006 Share Posted April 25, 2006 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 Link to comment https://forums.phpfreaks.com/topic/8331-file-upload-path/#findComment-30389 Share on other sites More sharing options...
JRS Posted April 25, 2006 Author Share Posted April 25, 2006 [!--quoteo(post=368274:date=Apr 25 2006, 12:05 AM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Apr 25 2006, 12:05 AM) [snapback]368274[/snapback][/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)ThanksJRS Quote Link to comment https://forums.phpfreaks.com/topic/8331-file-upload-path/#findComment-30392 Share on other sites More sharing options...
kenrbnsn Posted April 25, 2006 Share Posted April 25, 2006 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 Link to comment https://forums.phpfreaks.com/topic/8331-file-upload-path/#findComment-30398 Share on other sites More sharing options...
JRS Posted April 26, 2006 Author Share Posted April 26, 2006 [!--quoteo(post=368283:date=Apr 25 2006, 12:56 AM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Apr 25 2006, 12:56 AM) [snapback]368283[/snapback][/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 Quote Link to comment https://forums.phpfreaks.com/topic/8331-file-upload-path/#findComment-30811 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.