doddsey_65 Posted January 15, 2011 Share Posted January 15, 2011 i have an upload form and a posting form on the same page. when you upload a file it is uploaded to the server. what i am then trying to do is add the name of the file to $_SESSION['attachment'] so i can use it later. When the user posts their form i want the session to be inserted into the database but the session always comes up empty. this is what happens when they upload their file Setting the session and moving the file: session_start(); $_SESSION['attachment'] = "EXAMPLE"; move_uploaded_file($_FILES['Filedata']['tmp_name'], "../attachments/" . time() . $_FILES['Filedata']['name']); and then when they submit their form(textarea) it uploads the contents to the database and the contents of the session aswell. Why is this session always empty? Quote Link to comment https://forums.phpfreaks.com/topic/224503-sessions/ Share on other sites More sharing options...
dragon_sa Posted January 15, 2011 Share Posted January 15, 2011 $_SESSION['attachment'] = basename( $_FILES['Filedata']['name']); this should give you the filename in the session then you can just echo $_SESSION['attachment']; or what ever you need Quote Link to comment https://forums.phpfreaks.com/topic/224503-sessions/#findComment-1159686 Share on other sites More sharing options...
doddsey_65 Posted January 15, 2011 Author Share Posted January 15, 2011 i know how to get the actual filename into the session i just used "example" as an example. but either way it doesnt write the session. Quote Link to comment https://forums.phpfreaks.com/topic/224503-sessions/#findComment-1159687 Share on other sites More sharing options...
dragon_sa Posted January 15, 2011 Share Posted January 15, 2011 have you got session_start(); at the top of every page using the session variables?, I can see on this bit of code you have but that doesnt show us much of how you are writing it anywhere else what happens if you echo the session on the page you create it on after the move upload file bit? Quote Link to comment https://forums.phpfreaks.com/topic/224503-sessions/#findComment-1159691 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.