Hi, I am new to php, and I need to do multiply image upload. Right now I have single image upload which is not working.., so any adive would be appreciated.

Here is part of form I use for image upload:

<i>Vyber obrázek:</i> <input type="file" name="imagefile" />
 <br /><br /><br />

<input type="submit" name="submit" value="Uložit" />

And here is part of the action script:

<?php

require_once ("includes/globals.php");

openpage();     

if(isset($_POST['submit'])) { 


//UPLOAD IMAGE----------------------------------------------

if ($_FILES['imagefile']['type']=="image/jpeg")
{
$create = @ImageCreateFromJPEG(''.$_FILES['imagefile']['tmp_name'].'');
$image = @Imagejpeg($create, 'fotky/'.$_FILES['imagefile']['name'].'');
}
if ($_FILES['imagefile']['type']=="image/png")
{
$create = @ImageCreateFromPNG(''.$_FILES['imagefile']['tmp_name'].'');
$image = @Imagepng($create, 'fotky/'.$_FILES['imagefile']['name'].'');
}
if ($_FILES['imagefile']['type']=="image/jpg")
{
$create = @ImageCreateFromJPEG(''.$_FILES['imagefile']['tmp_name'].'');
$image = @Imagejpeg($create, 'fotky/'.$_FILES['imagefile']['name'].'');
}
if ($_FILES['imagefile']['type']=="image/gif")
{
$create = @ImageCreateFromGIF(''.$_FILES['imagefile']['tmp_name'].'');
$image = @Imagegif($create, 'fotky/'.$_FILES['imagefile']['name'].'');
}
if ($_FILES['imagefile']['type']=="image/pjpeg")
{
$create = @ImageCreateFromJPEG(''.$_FILES['imagefile']['tmp_name'].'');
$image = @Imagejpeg($create, 'fotky/'.$_FILES['imagefile']['name'].'');
}
 
@unlink(''.$_FILES['imagefile']['tmp_name'].'');
@ImageDestroy($create);


//I cant get past this point.. 
if (!$create) {
echo 'Upload image failed!
<a href="new.php">Back</a>';
closepage();
exit;
}
                                                        
                         
$path = 'fotky/';
$pic = $_FILES['imagefile']['name'];
$picture = $path.$pic;


mysql_query("INSERT INTO list (id_user, fotky) VALUES ('".$id."', '".$picture."')");

     echo'New picture: '.$picture.'<br />';

 }
 
closepage();

?>
Member Avatar for diafol

Have you searched the forum for this - or even Google? There are many, many posts on this.

Have you searched the forum for this - or even Google? There are many, many posts on this.

Yes, thats how I made this, and I dont know why it doesnt work

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.