I am fairly new to image uploaders (worked in animation for a long time).

I have an image upload form that works fine. The image uploads and redirects to another PHP page (imageupload_file.php) that confirms the image uploaded and gives you the name of the image and size on the server.

By clicking a link you go through to another page (galleryinsert.php) where you can add the image details to, such as page to be shown on, section on the page.

The only thing I cant do is get the image name to echo in the second details page. At the moment I have to copy and paste the name into galleryinsert.php and this is quite messy.

Is there a way I can save the image name as a variable and pass it through to the last form so I dont need to copy/paste it in?

Do you need to see the code?

Any help would be appreciated.

I don't know whether this is the best solution, but here it is:

<?php
// Note: this MUST be on the top of the page, without any whitespace whatsoever infront of it
session_start();
?>
<?php
$theimagename = "05-5098-40293050.jpg"; // You have retrieved this from your upload script
$_SESSION['imagename'] = $theimagename;
?>

Then you can retrieve that session variable on the next page:

<?php
// Note: this MUST be on the top of the page, without any whitespace whatsoever infront of it
session_start();
?>
<?php
$theimagename = $_SESSION['imagename'];
echo $theimagename;
?>

I am fairly new to image uploaders (worked in animation for a long time).

I have an image upload form that works fine. The image uploads and redirects to another PHP page (imageupload_file.php) that confirms the image uploaded and gives you the name of the image and size on the server.

By clicking a link you go through to another page (galleryinsert.php) where you can add the image details to, such as page to be shown on, section on the page.

The only thing I cant do is get the image name to echo in the second details page. At the moment I have to copy and paste the name into galleryinsert.php and this is quite messy.

Is there a way I can save the image name as a variable and pass it through to the last form so I dont need to copy/paste it in?

Do you need to see the code?

Any help would be appreciated.

yes, you need to show the part of code too.
There you must be having something like -

header("Location:imageupload_file.php");

we just need to ensure that it goes like this -

header("Location:imageupload_file.php?img_name=$img_name");

So $img_name will carry the image name from the current page to the next page, which you can display in the imageupload_file.php as

echo "Image you uploaded: ".$_GET['img_name'];

also write like this.if youwant to redirect only to another page write like this.
in the first page:

<form name="formx" action="nextpage.php" method="post" enctype="multipart/form-data">
<table>
<tr>
<td>
<input name="image" type="image">
<input type="submit" name="submit" value="submit">
</td>
</tr>
</table>
</form>

and in next page at the top of the page mention like this.

<?php
ob_start();
extract($_REQUEST);
echo $_REQUEST['image'];exit;
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.