Jump to content

[SOLVED] simple problem


onthespot

Recommended Posts

Well that line assigns the variable $imagename to the uploaded file name. So if your uploaded file is somefile.txt then $imagename will be set as somefile.txt

 

If you want the uploaded file to be named the value of the $subject variable you'd use

$imagename = $subject;

if(isset($_POST['submit']))
		{


			if (isset ($_FILES['new_image']))
			{

				$imagename = $subject;
				$source = $_FILES['new_image']['tmp_name'];
				$target = "images/news/".$imagename;
				move_uploaded_file($source, $target);

				 if (move_uploaded_file($source, $target) == FALSE)
       echo "COULDNT MOVE FILE";

				$imagepath = $imagename;
				$save = "images/news/" . $imagepath; //This is the new file you saving
				$file = "images/news/" . $imagepath; //This is the original file

				list($width, $height) = getimagesize($file) ;

				$modwidth = 150;

				$diff = $width / $modwidth;

				$modheight = $height / $diff;
				$tn = imagecreatetruecolor($modwidth, $modheight) ;
				$image = imagecreatefromjpeg($file) ;
				imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;

				imagejpeg($tn, $save, 100) ;

				$save = "images/news/sml_" . $imagepath; //This is the new file you saving
				$file = "images/news/" . $imagepath; //This is the original file

				list($width, $height) = getimagesize($file) ;

				$modwidth = 80;

				$diff = $width / $modwidth;

				$modheight = $height / $diff;
				$tn = imagecreatetruecolor($modwidth, $modheight) ;
				$image = imagecreatefromjpeg($file) ;
				imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;

				imagejpeg($tn, $save, 100) ;
				echo "Large image: <img src='images/news/".$imagepath."'><br>";
				echo "Thumbnail: <img src='images/news/sml_".$imagepath."'>";

			}
		}

 

There is the code, I am trying to get the name at the end to be the variable $subject, but .jpg

Could you help?

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.