-2

Hello and thanks in advance i was working on file upload and I needed to create a profile page with image upload and resume upload. Resume upload was not a big deal but in case of image I want user to upload a image and the uploaded image will be viewed on his profile as profile picture, so I wanted to know the fields in the table for a image (for ex like name, id, size, )

How do I retrieve the image on my php page?

This is what I have done to upload a resume and the code works fine but i dont have idea for images/picture:

$name=$_FILES["file"]["name"];
$size=$_FILES["file"]['size']/1024;
$temp=$_FILES["file"]["tmp_name"];
$path = "uploads/";

move_uploaded_file($_FILES["file"]["tmp_name"],"uploads/" . $_FILES["file"]["name"]);

echo "Upload: ". [$_FILES["file"]["name"] ;
echo '<br>';
echo "Type: " . $_FILES["file"]{"type"] ;
echo '<br>';
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB";
echo '<br>';
echo "Stored in: " . "uploads/" . $_FILES["file"]["name"]. ""; 
echo '<br>';
Meenesh Jain
  • 2,532
  • 2
  • 19
  • 29
  • If you need the image for the profile picture then add a column named image or something(where you can store the location of the user's uploaded image) in the table where you are storing the user details, you can retrieve the image when you display the user details based on the id of the user. – CAO Sep 20 '13 at 17:36
  • yeah i wanted image for profile picture.. – Meenesh Jain Sep 21 '13 at 14:43
  • Then you need to follow the same procedure, here like you are uploading images, then store their address in the table where you are storing the user's info, and when you retrieve the user's details then retrieve the images based on their address. Hint: Use $_SESSION , this is what you need – CAO Sep 21 '13 at 15:03

1 Answers1

0

The procedure for image will be exactly same, you can simply create a table with following fields, id, imagename,imagelocation, user_id, where user_id is foreign key to users table assuming user table as parent table

Now simply make a fetch on this image table while rendering user profile page and you are done, nothing complicated, every thing is on Google

Manish Goyal
  • 700
  • 1
  • 7
  • 17