Jump to content

transfering data between forms


arbitter

Recommended Posts

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

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.

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..

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.