Upload vise fotografija odjednom. Forma

Name:
E-mail:
Phone:
Photo:
Photo:
Photo:
Photo:

A ovo je moj add.php

<?php //This is the directory where images will be saved $target = "images/"; $target = $target . basename( $_FILES['photo[ ]']['name']); //This gets all the other information from the form $name=$_POST['name']; $email=$_POST['email']; $phone=$_POST['phone']; $filename=($_FILES['photo[ ]']['name']); // Connects to your Database mysql_connect("localhost", "root", "123") or die(mysql_error()) ; mysql_select_db("employees") or die(mysql_error()) ; //Writes the information to the database mysql_query("INSERT INTO `employees` VALUES ('$name', '$email', '$phone', '$filename')") ; //This function separates the extension from the rest of the file name and returns it function findExtension ($filename) { $filename = strtolower($filename) ; $exts = explode(".", $filename) ; $n = count($exts)-1; $exts = $exts[$n]; return $exts; } //This applies the function to our file $ext = findExtension ($_FILES['photo[ ]']['name']) ; //This line assigns a random number to a variable. You could also use a timestamp here if you prefer. $ran = rand () ; //This takes the random number (or timestamp) you generated and adds a . on the end, so it is ready of the file extension to be appended. $ran2 = $ran."."; //This assigns the subdirectory you want to save into... make sure it exists! $target = "images/"; //This combines the directory, the random file name, and the extension $target = $target . $ran2.$ext; if(move_uploaded_file($_FILES['photo[ ]']['tmp_name'], $target)) { echo "The file has been uploaded as ".$ran2.$ext; } else { echo "Sorry, there was a problem uploading your file."; } ?> <? $uploaddir = "images/"; if(isset($_FILES) && is_array($_FILES) && count($_FILES)>0){ foreach($_FILES as $file) { echo "Attempting to Upload
"; if(move_uploaded_file($file["tmp_name"],$uploaddir.$file["name"])){ echo "Uploaded File"; if ($file['type']!="image/jpeg"){ echo "Non Image"; unlink($uploaddir.$file["name"]); } else{ echo "Image file"; } } else{ echo "Could not Upload File
"; } } } else{ echo "Error"; } ?>

Prijavljuje mi gresku Undefined index: photo[ ]

Svaka pomoc bi mi bila dobrodosla…

Zašto ne probaš već sa gotovim rješenjem. Ja koristim ovo http://www.plupload.com/

Ime key-a u arrayu nije photo[] nego photo, to photo[] oznacava samo da je array i to u html-u

Hvala vam na pomoci!


Copyright © 2020 WM Forum - AboutContact - Sponsored by: Mydataknox & Webmaster.Ninja