1,105,312 Community Members

Image upload

Member Avatar
Mykybo
Newbie Poster
2 posts since Mar 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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
diafol
Where are my eyes?
12,961 posts since Oct 2006
Reputation Points: 1,821 [?]
Q&As Helped to Solve: 1,847 [?]
Skill Endorsements: 92 [?]
Moderator
Featured
Sponsor
 
0
 

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

Member Avatar
Mykybo
Newbie Poster
2 posts since Mar 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: