Multiple upload and Resize
Posted on
16th Feb 2014 07:03 pm by
admin
I would like some help on my script I have the for my index.php
////
<html>
<head>
<!-- Include the javascript -->
<script src="multifile_compressed.js"></script>
</head>
<body>
<!-- This is the form -->
<form enctype="multipart/form-data" action="upload.php" method = "post">
<!-- The file element -- NOTE: it has an ID -->
<input id="my_file_element" type="file" name="file_1" >
<input type="submit">
</form>
Files:
<!-- This is where the output will appear -->
<div id="files_list"></div>
<script>
<!-- Create an instance of the multiSelector class, pass it the output target and the max number of files -->
var multi_selector = new MultiSelector( document.getElementById( 'files_list' ), 3 );
<!-- Pass in the file element -->
multi_selector.addElement( document.getElementById( 'my_file_element' ) );
</script>
</body>
</html>
//////
For my upload.php
but this script is for only one image
///
<?php
if(isset($_POST['submitimg'])){
if (isset ($_FILES['new_image'])){
$imagename = $_FILES['new_image']['name'];
$source = $_FILES['new_image']['tmp_name'];
$target = "../Dphotos/".$imagename;
move_uploaded_file($source, $target);
$imagepath = $imagename;
$save = "../Dphotos/" . $imagepath; //This is the new file you saving
$file = "../Dphotos/" . $imagepath; //This is the original file
list($width, $height) = getimagesize($file) ;
$modheight = 350;
$diff = $height / $modheight;
$modwidth = $width / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagejpeg($tn, $save, 100) ;
$save = "../Dphotos/thumbs/" . $imagepath; //This is the new file you saving
$file = "../Dphotos/" . $imagepath; //This is the original file
list($width, $height) = getimagesize($file) ;
$modheight = 100;
$diff = $height / $modheight;
$modwidth = $width / $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='../Dphotos/".$imagepath."'>
";
echo "Thumbnail: <img src='../Dphotos/thumbs/".$imagepath."'>";
}
}
?>
/////
Please help thanks
No comments posted yet
Your Answer:
Login to answer
93
35
Other forums
Display certain image depending on time of year
Hi, I am new to these forums and would really appreciate some advice on a piece of coding I have don
Linking with Foreign Keys
I have been getting an erro when I try and link:
create table Faculty_Specialty (I_Name v
Bit manipulation program with binary operations
My homework is to create a program to scan in and add binary numbers and print them like so
Automatic Webpage ??
I have a page www.mysite.com/test.php with a
<form>
<textarea name=&q
BAPI BBP_INB_DELIVERY_CREATE - material number missing in delivery
Hi Experts,
I was able to successfully create an Inbound delivery with reference to a PO
Production of mango in processing industry
Hi,
We have one scenario ,company is in process industry,they are manufacturing MANGO pul
Allegro crashes when running load_bitmap. Why?
I can not get Allegro to load any BMP images. Here is a section of test code. The picture is in the
Displaying data from MySql a different way
Hi all,
I'm pretty new to php and MySql and have hit a problem.
I am able to display data
LSB (PHP 5.3) problem with static value!
hello,
i'm having a problem. static::$text variable gets lost at some point. can someone plea
TinyMCE / Ajax Postback Problem
Hiya all,
I have a page which loads the TinyMCE editor. On the postback I obviously want to f