• (3 Pages)
  • +
  • 1
  • 2
  • 3

Uploading Images with PHP Build the next Flickr! (DICr???) Rate Topic: ***** 7 Votes

#16 akozlik  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 90
  • View blog
  • Posts: 797
  • Joined: 25-February 08

Posted 06 October 2009 - 11:03 AM

Just add a where clause that selects the image associated to the user profile.

You could have a db schema like the following

users
- user_id
- username
- password
- last_login_date

user_profiles
- user_id
- fname
- lname
- profile_image

When you input a user into the users table, you also input a blank record into user profiles where user_id equals the last inserted id on the users table. You can get this with the mysql_insert_id() function.

Then you do a sql like

select profile_image from user_profiles where user_id = '$user_id'



That should be enough to get you started.
Was This Post Helpful? 0
  • +
  • -

#17 mulson  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 11
  • Joined: 21-September 09

Posted 09 October 2009 - 12:45 AM

View Postakozlik, on 6 Oct, 2009 - 10:03 AM, said:

Just add a where clause that selects the image associated to the user profile.

You could have a db schema like the following

users
- user_id
- username
- password
- last_login_date

user_profiles
- user_id
- fname
- lname
- profile_image

When you input a user into the users table, you also input a blank record into user profiles where user_id equals the last inserted id on the users table. You can get this with the mysql_insert_id() function.

Then you do a sql like

select profile_image from user_profiles where user_id = '$user_id'



That should be enough to get you started.


Ok,I will start with that,and will alert you later...thanx alot)
Was This Post Helpful? 0
  • +
  • -

#18 mulson  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 11
  • Joined: 21-September 09

Posted 14 October 2009 - 06:20 AM

my table is like this:
employees-table name
name
email
phone
photo
and i run my code like this:
<html>
<head>
<title>photos</title>
</head>
<body>
<table width=800 height=600><tr><td><nop></td><td>
<?php
//lets make connection to the database
include "config.php";

$name= $_POST['name'];
$email= $_POST['email'];
$phone = $_POST['phone'];
$photo = $_POST['photo'];

//request for the message itself
$query = "SELECT photo from employees where name='$name'; 
          "; 
$thm = mysql_query($query);

if(!$thm) puterror("ERROR:a mistake occured,messages cannot shown");

//Total number of shown messages
//$count = mysql_result($tot,0);

//Puts it into an array 
while($info = mysql_fetch_array( $thm)) 
{ 
//Outputs the image and other data
echo "<img src=http://senkerr.vndv.com/images/$info[photo] width=100 height=100><br>"; 
Echo "<b>Name:</b> ".$info['name'] . "<br> ";
Echo "<b>Email:</b> ".$info['email'] . " <br>";
Echo "<b>Phone:</b> ".$info['phone'] . " <hr>";
}
?>

There is no mistake,but there is no image....can you help me out,please?
why is the image not coming,the field that holds the image is photo(it holds only the image name with its extension(.jpeg,.png,.gif...))
Was This Post Helpful? 0
  • +
  • -

#19 akozlik  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 90
  • View blog
  • Posts: 797
  • Joined: 25-February 08

Posted 14 October 2009 - 09:24 AM

Check the HTML source code. Is the image creating a full URL to an image? If so, make sure that the image is actually in the directory it's expected to be.

Let me know what you find.
Was This Post Helpful? 0
  • +
  • -

#20 izoo32  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 25-February 10

Posted 25 February 2010 - 03:28 AM

please help me i have tried to use your scripts but it has failed whenever i send or submit it brings me a blank page. what can i do here please help
thanx
Was This Post Helpful? 0
  • +
  • -

#21 akozlik  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 90
  • View blog
  • Posts: 797
  • Joined: 25-February 08

Posted 25 February 2010 - 03:59 PM

View Postizoo32, on 25 February 2010 - 05:28 AM, said:

please help me i have tried to use your scripts but it has failed whenever i send or submit it brings me a blank page. what can i do here please help
thanx


You need to give me more information. What is the error that you're getting? Make sure error reporting is turned on. Also make sure that the directory you're writing to has the proper permissions set.
Was This Post Helpful? 0
  • +
  • -

#22 Guest_dulla20*


Reputation:

Posted 26 April 2010 - 11:00 AM

Hey Man,

Thanks for the tutorial. Anyways, wen i try to upload the photos it is giving me an error : "Column 'image' cannot be null". What are the possible mistake that i have done.

Thanks
Was This Post Helpful? 0

#23 clatcho  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 59
  • Joined: 14-February 07

Posted 27 April 2010 - 02:23 PM

Works just like magic
Was This Post Helpful? 0
  • +
  • -

#24 Guest_Guest*


Reputation:

Posted 10 August 2010 - 04:39 AM

Thank you for this tutorial it was very nice but I want to know how to upload a multiple images at once this tutorials show how to upload one image what if I want to upload a multiple images like a gallery so every user can have his own images
Thanks again

Yousef Altaf
Was This Post Helpful? 0

#25 mdmartiny  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 85
  • Joined: 28-May 10

Posted 20 January 2011 - 06:21 PM

I would like to thank the writer of this tutorial. I have been looking for a way to do this for quite some time. This tutorial has been very helpful in answering some of my questions.

Now I need to learn how to show the individual image that is uploaded to the server.
Was This Post Helpful? 0
  • +
  • -

#26 Guest_Patrick*


Reputation:

Posted 12 February 2011 - 04:05 AM

Thanks for this great tutorial. I'm running Xampp and it works great. But i still have a question is it possible to load each image in the images.php in his own div. So i could make rectangles of div's and put inside the pics. thanks in advance you're the man.

Greets from patrick
Was This Post Helpful? 0

#27 WMWDesign  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 14-February 11

Posted 16 February 2011 - 05:39 PM

Just a note about your file structure: it is a good idea to put the connection information in a folder above the root directory. As the structure is right now, hackers have easy access to your database information.

This post has been edited by WMWDesign: 16 February 2011 - 05:40 PM

Was This Post Helpful? 0
  • +
  • -

#28 nuckalheads  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 01-March 11

Posted 01 March 2011 - 10:32 AM

I tried everything to change the file name with timestamp and MD5. In what part of the upload script would I edit to give the file a unique name???
Was This Post Helpful? 0
  • +
  • -

#29 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6066
  • View blog
  • Posts: 23,526
  • Joined: 23-August 08

Posted 02 March 2011 - 01:14 PM

Create the filename and use it as part of the path you're passing in the second argument to move_uploaded_file.
Was This Post Helpful? 0
  • +
  • -

#30 nuckalheads  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 01-March 11

Posted 05 March 2011 - 10:22 PM

// Lets attempt to move the file from its temporary directory to its new home
if (move_uploaded_file($image['tmp_name'], $TARGET_PATH))

Is this where I would edit to produce a random number for the file going into the folder and database?
?? and will the file name be the same in both???

This post has been edited by nuckalheads: 05 March 2011 - 10:23 PM

Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3