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
php ajax - two drop down list with a submit button
i have created a form with 2 drop-down list and a submit button. I would like to know how to pass th
Something like an INI editor or a DelimitedText-Editor
Hi all,
Am very, very, very new to PHP and not sure if I should be posting this to a Javascri
difference between datetimes
($row['totime']-$row['fromtime'])/60
this is giving me 0
example of totime and fromtim
Big Problem!! Please help
Hi Guys,
Im making a website for a friend have encountered a really annoying problem. When ev
opening a window with after form submission
I know this this forum has nothing to do with JS, but i'm trying to use it with my php script.
<
Setting condidtions for an input box
Hi all,
I would like to set a condition in a txt box that says the number a user enters has t
Checking if a process is running (problems including psapi.dll i think...)
Ok, so all I'm trying to do is check if a program is running...
I've found out that I nee
wav to mp3 + goDaddy
I need to convert wav files to mp3s. From what I have found so far one way to do it is to have my PH
MVC - Code review
I'm in the process of trying to wrap my head around MVC, and as part of that, I'm attempting to impl
controlling/creating accounts with privileges
hi all,
i'm trying to figure out how i can create/control account with privileges, for instance a