Jump to content

Find out what was posted.


ActaNonVerba1

Recommended Posts

Hey guys.

 

I have a page which posts images to itself.

The name on the <input type file> changes each time. Its in the format of 'Thumbnail#' eg. Thumbnail1 Thumbnail2 etc. This can only be up to Thumbnail28.

How can i work out which number  was posted, and then use the number? There will always be 2. Eg if there is a thumbnail1 there will be a thumbnail 2 as thumbnails have to come in packs of 2.

 

Heres my current code.

<?php
session_start();
if ($_SESSION['adminlogin'] == 1){
	//Run
}
else {
header('Location: Log-In.php');
exit;
}
?>
  
<?php
$warnings = '<b>Errors:</b><br>';
//Data from Edit-Page.php first time
$Name = $_GET['name'];
$TypeOfEdit = $_GET['typeofedit'];
$LightType = $_GET['lighttype'];
$LightName = $_GET['lightname'];
$NumberOfThumbnailsRequired = $_GET['numberofthumbnails'];
$PageLocation = $_GET['pagelocation'];

//Data from this page second time
$Name = $_POST['Name'];
$TypeOfEdit = $_POST['TypeOfEdit'];
$LightType = $_POST['LightType'];
$LightName = $_POST['LightName'];
$PageLocation = $_POST['PageLocation'];

//Work out name of each thumb/large
$Thumbnailname = 'NameofThumbnail'; ###########################################################################################################################
$Largename = 'NameofLarge'; ###################################################################################################################################

//Work out location to move each thumb to & create it if need be

$target_path_thumbnails = '../Images/'.$LightType.'/'.$LightName.'/Mini';
$target_path_without_mini = '../Images/'.$LightType.'/'.$LightName;
$target_path_thumbnails_and_extension = $target_path_thumbnails.'/'.$Thumbnailname.'.png';

$target_path_large = '../Images/'.$LightType.'/'.$LightName.'/'.$Largename.'.jpg';

if (file_exists($target_path_thumbnails)) {
	//Do nothing.
} else {
	if (file_exists ($target_path_thumbnails_without_mini)) {
		mkdir($target_path_thumbnails,0777);
	} 
	else {
	mkdir($target_path_thumbnails_without_mini,0777);
	mkdir($target_path_thumbnails,0777);
	}
}	

//Move uploaded thumbnial to this location
if(move_uploaded_file($_FILES[$Thumbnailname]['tmp_name'], $target_path_thumbnails)) {
	$Thumbnailname = 'http://www.worldwidelighthouses.com/Images/'.$LightType.'/'.$LightName.'/'.$Thumbnailname.'.png';;
} 
else{
	$warnings = $warnings."There was an error uploading the thumbnail file, please try again!<br>";
	$Thumbnailname = "";
}
if(move_uploaded_file($_FILES[$Largename]['tmp_name'], $target_path_large)) {
	$Thumbnailname = 'http://www.worldwidelighthouses.com/Images/'.$LightType.'/'.$LightName.'/'.$Thumbnailname.'.png';;
} 
else{
	$warnings = $warnings."There was an error uploading the large image file, please try again!<br>";
	$Thumbnailname = "";
}	
if (!isset($NumberOfThumbnailsLeft)){$NumberOfThumbnailsLeft = $NumberOfThumbnailsRequired;}

$FirstThumbnailPostName = $NumberOfThumbnailsRequired - $NumberOfThumbnailsLeft + 1;
$SecondThumbnailName = $FirstThumbnailPostName + 1;
?>
<!DOCTYPE HTML>
<html lang="en-GB">
<head>
            <meta charset="utf-8">
            <!--Search Engine Meta Tags--> 
            <meta name="author" content="Worldwide Lighthouses">
            <meta name="keywords" content="Lighthouses,Lightships,Trinity House,Fog Signals,Fog Horns,Fresnel">
            <meta name="description" content="Worldwide Lighthouses is the number 1 source of information, pictures and videos on the Subject of Lighthouses and Lightships">
            <!--Stylesheets/Javascript-->
            <link rel="stylesheet" href="../../../Page-Layout.css" media="screen and (min-width: 481px)">
            <link rel="stylesheet" href="../../../Mobile-Page-Layout.css" media="only screen and (max-width:480px)">
            <link rel="stylesheet" href="EditPageCSS.css">
<!--Mobile Browser Support-->
            <meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
            <!--IE Support-->
            <!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <link rel="stylesheet" href="../Page-Layout.css"><![endif]-->
<meta name="application-name" content="Worldwide Lighthouses"> 
	<meta name="msapplication-starturl" content="http://worldwidelighthouses.com/"> 
        	<meta name="msapplication-tooltip" content="Worldwide Lighthouses: Your number one source of Lighthouse Information, Videos and Pictures"> 
        	<meta name="msapplication-task" content="name=Lighthouses;action-uri=http://worldwidelighthouses.com/Lighthouses.php;icon-uri=http://worldwidelighthouses.com/IE9/Lighthouses.ico"> 
        	<meta name="msapplication-task" content="name=Lightships;action-uri=http://worldwidelighthouses.com/Lightships.php;icon-uri=http://worldwidelighthouses.com/IE9/Lightships.ico"> 
	<meta name="msapplication-task" content="name=Fog Signals;action-uri=http://worldwidelighthouses.com/Fog-Signals.php;icon-uri=http://worldwidelighthouses.com/IE9/Fog-Signals.ico"> 
       		<meta name="msapplication-task" content="name=Glossary;action-uri=http://worldwidelighthouses.com/Glossary.php;icon-uri=http://worldwidelighthouses.com/IE9/Glossary.ico">
            	<title>Add Thumbnails to <?php echo $Name?> | Worldwide Lighthouses</title>
          </head>
<body>
<div id="loading"><div id="loadinginfo"><img src="upload.gif" width="128" height="15" alt="Uploading"><br><h1>Uploading images...</h1><p>Please Wait, this could take a while.</p></div></div>
  <header>
	<h1 id="WWLH">Worldwide Lighthouses</h1>
	<form method="get" action="http://www.worldwidelighthouses.com/Search/search.php" id="Search-Box">
		<input type="search" placeholder="Search Worldwide Lighthouses" name="query" id="query" size="30" value="" autocomplete="off">	
		<input type="submit" value="Search">
           		<input type="hidden" name="search" value="1"> 
  		</form>
</header> 	<nav>
  		<ul id="Nav">
		<li class="MenuButton" id="Index"><a href="http://www.worldwidelighthouses.com/Index.php"><p class="Nav">Home</p></a></li>
       		<li class="MenuButton" id="Lighthouses"><a href="http://www.worldwidelighthouses.com/Lighthouses.php"><p class="Nav">Lighthouses</p></a></li>
       		<li class="MenuButton" id="Lightships"><a href="http://www.worldwidelighthouses.com/Lightships.php"><p class="Nav">Lightships</p></a></li>
       		<li class="MenuButton" id="FogSignals"><a href="http://www.worldwidelighthouses.com/Fog-Signals.php"><p class="Nav">Fog Signals</p></a></li>
            <li class="MenuButton" id="Daymarks"><a href="http://www.worldwidelighthouses.com/Daymarks.php"><p class="Nav">Daymarks</p></a></li>
            <li class="MenuButton" id="Buoys"><a href="http://www.worldwidelighthouses.com/Buoys.php"><p class="Nav">Buoys</p></a></li>
       		<li id="MenuButtonLast"><a href="http://www.worldwidelighthouses.com/Glossary.php"><p class="Nav">Glossary</p></a></li>
	</ul>
</nav>
        <?php
	if ($_SESSION['adminlogin']==1) {
		echo '<div id="logout">
			  <div style="float:left; width:30%; text-align:left;!important">
			  <a href="Log-In-Accept-Deny.php">Back to Admin Home</a>
			  </div>
			  <div style="float:right; width:70%;">
			  <a href="Logout.php">Log Out of Admin</a>
			  <p style="font-size:10px;">Always Sign Out when Finished!</p>
			  </div></div>';}
?> 
<article>
    <h1 class="Title">Add Thumbnails to <?php echo $Name?></h1>
  <div class="Textbox">
      <form method="post" action="<?php echo 'http://www.worldwidelighthouses.com'.$_SERVER['PHP_SELF'] ?>" id="EditPage">
      <input type="hidden" name="numberofthumbnailsleft" value="<?php echo $NumberOfThumbnailsLeft ?>">
      	<h2>Upload Thumbnails</h2>
            <div style="height:150px;">
            <div class="PhotoExplainForm"><img src="<?php echo $DisplayImage1 ?>" width="322.5" height="150"><br><span class="thumb">Format: .PNG</span></div>
            <div class="RightSideFormImage"><label class="Large">Thumbnail <?php echo $FirstThumbnailPostName ?><span class="req">*</span></label><input type="file" class="reqimage" <?php echo $ImageReq; ?> accept="image/x-png" name="Thumbnail<?php echo $num ?>"></div>
            </div>
		<?php echo $DisplayImage2 ?>
            <div style="height:150px;">
            <div class="RightSideFormImage"><label class="Large">Thumbnail <?php echo $SecondThumbnailName ?><span class="req">*</span></label><input type="file" class="reqimage" <?php echo $ImageReq; ?> accept="image/x-png" name="Thumbnail<?php echo $num+1 ?>"></div>
            </div>
            
            <h2>Upload Large Images</h2>
            <div style="height:250px;">
            <div class="PhotoExplainForm"><img src="<?php echo $DisplayImage3 ?>" width="322" height="242"><br><span class="thumb">Format: .JPG</span></div>
            <div class="RightSideFormImage"><label class="Large">Large Image <?php echo $num ?></label><p class="Explination">(The large image shown when a thumbnail is clicked - not required)</p><input type="file" class="reqimage" <?php echo $ImageReq; ?> accept="image/jpeg" name="Large<?php echo $FirstThumbnailPostName ?>"></div>
            </div>
		<?php echo $DisplayImage4 ?>
            <div style="height:250px;">
            <div class="RightSideFormImage"><label class="Large">Large Image <?php echo $SecondThumbnailName ?></label><p class="Explination">(The large image shown when a thumbnail is clicked - not required)</p><input type="file" class="reqimage" <?php echo $ImageReq; ?> accept="image/jpeg" name="Large<?php echo $num+1 ?>"></div>
            </div>
            <input type="submit" value="Continue »" id="continue" onClick="setVisibility('loading', 'block');">
      </form> 
      <?php
      if ($_SESSION['adminlogin'] == 1){
	echo "Logged in on server side.";
}?>
    </div>
</article>
    <footer>
    <ul>
	<li><a href="http://www.worldwidelighthouses.com/About.php">About</a></li>
        <li><a href="http://www.worldwidelighthouses.com/Contact-us.php">Contact</a></li>
        <li><a href="http://www.worldwidelighthouses.com/Use-Our-Media.php">Use our media</a></li>
        <li><a href="http://www.worldwidelighthouses.com/Search/search.php">Search</a></li>
        <li><a href="http://www.worldwidelighthouses.com/Social-Networking.php">Social</a></li>
        <li><a href="#Top">Back to top</a></li>
    </ul>
    <br>
    <br>
    	&#169; Worldwide Lighthouses <?php echo date("Y"); ?>
</footer>
</body>

 

Any or all help is appreciated.

 

Cheers

Danny.

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.