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
returning data from an ssh2_exec()
here's what i got.
$conn = ssh2_connect($this->_host);
ssh2_auth_password($c
Confusing Functions
So, I've been reading up on Functions and I like them! However, I need some help using variables in
Form always sends to error page...
Hello,
Any help will be greatly appreciated. I am having trouble getting multiple fields to be re
Am I setting up my sites oldschool?
Ok,
When I create a site I open a basic template that I have created that consists of a css f
Is this possible? If one file assigned to an ID...
I have a page that lists property listings assigned to a specific user (a manage page), with brief t
Trouble verifying database password
Thankyou to everyone who responded to my last post (I can't find the posting, it has been buried). <
Header is not working in IE
Hi ! header function is not working in IE but it works in FF, Safari, Chrome. any help please. :
Login Script Issues
I am using a script I got from http://phpsense.com/php/php-login-script.html in order to allow peopl
Will this protect from mysql injection?
I do not want anything like DROP TABLE to work or any type of coding..
Heres my code.. is it
PHP onsubmit in the form not going to the fuction.
I have a form through ‘onsubmit’ calling a function validation(). But not going to the