Jump to content

Insert and view Uploaded PICS on the web page


uisneach

Recommended Posts

Hello, noob here

 

Just ask you this

I am bulding a website for a photographer.

Need to upload pics from the net,  choosen by client, then move this pics into the the website to be viewed

I created something like this and it works. I checked and the pics are found on my linux server.

So i have a table on the  db mysql where  the pics details are correctly saved

Now I need to insert last pic uploaded on my web page, "pictureview.php."with name and descriptio but I don't really have a clue about how to make the first step!!!

 

please, someone may give me some advices?

 

Thx in advance:)))))

 

Paolo

 

$host = "xxcxcx";

$user = "xcxcxcx";

$password = "xcxcxcxx";

$dbname = "xcxcxcxcx";

 

$cxn = mysql_connect($host,$user,$password);

mysql_select_db($dbname);

 

if (!$cxn)

    echo 'Error server MySQL'; 

 

exit();

 

  } 

 

 

 

else  {

$insertSQL = "INSERT INTO foto (description) VALUES ('".$_POST['description']."')";

to

 

mysql_select_db($dbname);

 

 

$Result1 = mysql_query($insertSQL) or die(mysql_error());

 

$ultimo_id = mysql_insert_id();

 

$file_temp=($_FILES['userfile']['tmp_name']);

 

 

$percorso="public/foto/";

 

 

$nuovo_nome=$percorso.$ultimo_id.".jpg";

 

 

$inviato = file_exists($file_temp);

 

}

if ($inviato) {

 

    move_uploaded_file($file_temp,$nuovo_nome);

    header("Location:Pictureview.php");

 

    } else {

    header("Location:Errore.php");

    }

 

?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.