We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,633 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Image upload

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();

?>
2
Contributors
2
Replies
1 Hour
Discussion Span
1 Year Ago
Last Updated
3
Views
Mykybo
Newbie Poster
2 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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

diafol
Keep Smiling
Moderator
10,625 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,506
Skill Endorsements: 57

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

Mykybo
Newbie Poster
2 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.1094 seconds using 2.71MB