arbitter Posted March 6, 2010 Share Posted March 6, 2010 So I have this uploadform. You can give a title, a description, and upload a picture. The first form goes under the name 'submit', so in my php: if(isset($_POST['submit'])){ $file_tmp = $_FILES['Image']['tmp_name']; $file_name = $_FILES['Image']['name']; $file_type = $_FILES['Image']['type']; $file_size = $_FILES['Image']['size']; $title = $_GET['title']; $comment = $_GET['comment'];} (for example) It also does some tests, and asks you verification if you are sure you want to upload with those details. The next form looks like this: <form action='$_SERVER[php_SELF]' method='post' enctype='multipart/form-data'> <input type='hidden' value='$titel' name='titel'> <input type='hidden' value='$comment' name='bijschrift'> <input type='hidden' value='$file' name='vImage' /> <input type='submit' name='secondsubmit' value='Toch doorgaan'> </form> The only problem I have is that I don't know how the file and all those details, named in the first script, can go to the second script.. It's possible that there are some writing errorrs in the script, I just wanted to give a little clarity with an example..) Link to comment https://forums.phpfreaks.com/topic/194322-transfering-data-between-forms/ Share on other sites More sharing options...
cags Posted March 6, 2010 Share Posted March 6, 2010 The simplest solution would perhaps be to insert them into a SESSION on the first script. session_start(); if(isset($_POST['submit'])) { $_SESSION['files'] = $_FILES; $_SESSION['title'] = $_GET['title']; $_SESSION['comment'] = $_GET['comment']; } Then on the other script just access them using the $_SESSSION array. Link to comment https://forums.phpfreaks.com/topic/194322-transfering-data-between-forms/#findComment-1022297 Share on other sites More sharing options...
arbitter Posted March 6, 2010 Author Share Posted March 6, 2010 Well, after my post I thought of that as well. But it doesn't seem to be working... Do first I have if(isset($_POST['submit'])){ $file_tmp = $_FILES['vImage']['tmp_name']; $_SESSION['file_tmp'] = $file_tmp; etcetera But then: if(isset($_POST['secondsubmitp'])){ $file_tmp = $_SESSION['file_tmp']; list($width, $height) = getimagesize($file_tmp); I get an error with the getimagesize; failed to open stream: No such file or directory in *** With the data nothing should be wrong, since it's all the same, yet it isn't working.. When I didn't work around with a second form it did work.. Link to comment https://forums.phpfreaks.com/topic/194322-transfering-data-between-forms/#findComment-1022307 Share on other sites More sharing options...
cags Posted March 6, 2010 Share Posted March 6, 2010 Doing it item at a time like that would likely cause the file to go missing which is why I suggested just copying the $_FILES array, but even that likely will make the file disappear, you might have to save the image to a temp directory in the first script in order to keep access to it. Link to comment https://forums.phpfreaks.com/topic/194322-transfering-data-between-forms/#findComment-1022315 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.