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

Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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