Is there anyone who can explain to me how can i store image in a folder to the server then the path to mysql.
i dont know even how to get started,i will appreciate for your help.
Or links where i can find the tutorials.

Suppose this is your form in aaa.php

<table width="99%"  border="0" cellspacing="0" cellpadding="0">
        <tr>
          <th width="5%" height="62" scope="col">&nbsp;</th>
          <th width="51%" align="left" valign="top" scope="col"><form name="form2" method="post" action="aaa.php">
		//here you can view uploaded image
		  <img src="<?php echo $path ?>" height="150" width="150">
          </form></th>
          <th width="44%" align="left" valign="top" scope="col"><form action="aaa.php" method="POST" enctype="multipart/form-data">
    <p><br>
    <font size="1"></font><br>
    <table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
      <tr>
        <td width="246">
          <input type="hidden" name="MAX_FILE_SIZE" value="2000000">
          <input name="userfile" type="file" id="userfile">
        </td>
        <td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td>
      </tr>
    </table>
    <p><br>
    </form></th>
        </tr>
      </table>

create uploads folder in your directory and php code do store

$uploadDir = 'uploads/';

if(isset($_POST['upload']))
{
	
	$fileName = $_FILES['userfile']['name'];
	$tmpName = $_FILES['userfile']['tmp_name'];
	$fileSize = $_FILES['userfile']['size'];
	$fileType = $_FILES['userfile']['type'];
	
	$filePath = $uploadDir . $fileName;

	$result = move_uploaded_file($tmpName, $filePath);
	if (!$result)
	{
	//echo "Error uploading file";
	$filePath="uploads/no_images.jpeg";
	}
		
	if(!get_magic_quotes_gpc())
	{
	$fileName = addslashes($fileName);
	$filePath = addslashes($filePath);
	} 

	$query = "update table set path='$filePath' where user_id='$user_id'";//change query according to you
	
	mysql_query($query) or die('Error, query failed');
	$path=$filePath;
	//echo "<br>File $fileName uploaded<br>";

create column path in your database...to store path of image in database...which is in uploads folder

Thank you for the Code it works fine))
the problem comes when displaying the photos,so do i display them?
Also how do i save to database?bcoz i saved as varchar when i upload the photo i saw the whole link in my db.
when i saved as longblob i just saw the bait-34(a certain number))
thank you))

Suppose you have to display image which is uploaded for user1
display.php

<?php
//change query according to your table structure, column names
 $sql=mysql_query("SELECT * FROM table where user_fname='$user_fname'");
		  $row = mysql_fetch_array($sql);
		  $user_fname=$row['user_fname'];
		  $pass=$row['user_lname'];
		  $path=$row['path'];//here you get path where you store image for user1
?>

In table you have to write like

<table width="100%" style="height:157%"  border="0" cellpadding="0" cellspacing="0">
         <tr>
             <th scope="col" > 
		<img src="<?php echo $path ?>" height="150" width="150">
             </th>
         </tr>
 </table>

use like path varchar(30) to store image path in database or change size according to you

I think it solves your problem

Below is how i did)))but image still dont show up only area with width=500 and height=400 with an X.

<?php
//database connection routine
// Connecting to a MySql Database
include"config.php";
$user='peacemaker';
//selecting the path of the image for specific user
 $sql=mysql_query("SELECT * FROM picha where user='$user'");
		  $row = mysql_fetch_array($sql);
		  $user=$row['user'];
		  $filename=$row['filename'];
		  $path=$row['path'];//here you get path where you store image for user1
echo"<font color=blue> filename:$filename Usename: $user_fname<br></font>";// Display  original filename and username

		?>	  
				  
	<img src=<?php echo"$path";?> width=500 height=400>	<br>		  
		
		
	<?php

	echo"$path";	//here i just tried to view the file path	  
				  
	?>

after trying to view the file path it shows
c:/wamp/www/photo/uploads/Nicwa.jpg
where i`m i getting wrong???

Hi..
Confirm the filename and check if the file is getting properly uploaded.. check the path...

To show image img syntax is

<img src="" height="" width="">

not

<img src=<?php echo"$path";?> width=500 height=400>//wrong

i mentioned in earlier post (5)also ....
so do like that

<img src="<?php echo $path ?>" height="500" width="400">

Hi I have followed all the steps and I understand the concept behind uploading and displaying an image, however the image still does not display for me.

I believe the problem is with the rights of the file or something. The reason why I think so is because i have tried uploading an image to the "uploads" folder with ftp and i can easily display it however if i upload the same exact image with the upload form and then i try to view it I get the following message "403 Forbidden".

If it makes any difference I am using a hosted site.

Any idea why when i upload an image with the upload form it becomes forbidden in the folder?

Thank Sir .. I have learn your method and Can upload image successfully!!! :D

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.