Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <meta charset="utf-8">
- <title>HTML5 - Upload-Thumbnails (Vorschau) erstellen</title>
- </head>
- <body>
- <style type="text/css">
- #thumbnail img {padding:4px;max-width:100px;max-height:100px;}
- </style>
- <script type="text/javascript">
- function fileThumbnail(files)
- {
- var thumb = document.getElementById("thumbnail");
- thumb.innerHTML = "";
- if(!files)
- return;
- for(var i = 0; i < files.length; i++)
- {
- var file = files[i];
- if(!file.type.match(/image.*/))
- continue;
- var img = document.createElement("img");
- var reader = new FileReader();
- reader.onload = (function(tImg) {
- return function(e) {
- tImg.src = e.target.result;
- };
- })(img);
- reader.readAsDataURL(file);
- thumb.appendChild(img);
- }
- }
- </script>
- <form method="post" enctype="multipart/form-data" action="upload.php">
- Name<input type="text" name="name">
- <input type="file" name="image" accept="image/*" onChange="fileThumbnail(this.files);">
- <!--<input type="file" name="fileInput" accept="image/*" multiple onChange="fileThumbnail(this.files);">//-->
- <input type="submit" value="Hochladen">
- </form>
- <div>
- <div id="thumbnail"></div>
- </div>
- </body>
- </html>
- -------------------------------------
- <?php
- print_r($_POST);/*
- require_once('/main/class.upload.php');
- $name=$_POST['name'];
- $foo = new Upload($_FILES['image']);
- if ($foo->uploaded) {
- $foo->file_new_name_body = 'avatar';
- $foo->image_resize = true;
- $foo->image_convert = png;
- $foo->image_x = 100;
- $foo->image_y = 100;
- $foo->image_ratio = true;
- $foo->Process($name);
- if ($foo->processed) {
- echo 'image renamed, resized x,y=100
- and converted to png';
- $foo->Clean();
- } else {
- echo 'error : ' . $foo->error;
- }
- } */
- ?>
Advertisement
Add Comment
Please, Sign In to add comment