Jump to content

display all images from mysql on one page


justAnoob

Recommended Posts

I have the database set up up already. The content(the image) is stored as a blob in the db. I have an upload script that does its job so far. I am still working on making it more secure.(by the way, i thank everyone here for helping out with the upload script). Anyways, the upload script stores the picture, name, description of picture, the username of the user who uploaded it, and so on. I am trying to do two things here. Have one page to display all the images. And have another page where it only shows the pictures that were uploaded by the user that is currently signed in. Here is the upload script. I just need a kick in the butt for the display script.

<?php
session_start();
include ("upload_db_info.php");

if (!empty($_POST['upload']))
{
extract($_POST);
   	
if (isset($_POST['upload']) || $_FILES['upload_file']['size'] < 500000)
{
	$user = $_SESSION['id'];
	$fileName = $_FILES['upload_file']['name'];
        $tmpName = $_FILES['upload_file']['tmp_name'];
        $fileSize = $_FILES['upload_file']['size'];
        $fileType = $_FILES['upload_file']['type'];
    	if ( file_exists($tmpName) )
    	{
    		$content = file_get_contents($tmpName);
    	}
    }
  	$user = mysql_real_escape_string($user);      
$trade = mysql_real_escape_string($trade);
$picname = mysql_real_escape_string($picname);

$fileName = mysql_real_escape_string($fileName);
    $fileSize = (int)$fileSize;
    $fileType = mysql_real_escape_string($fileType);
    $content  = mysql_real_escape_string($content);
    
$descrip = mysql_real_escape_string($_POST["descrip"]);
$trade = mysql_real_escape_string($_POST["trade"]);
$picname = mysql_real_escape_string($_POST["picname"]);

$query = "INSERT INTO UploadedFiles (name, size, type, content, user, descrip, trade, picname)VALUES('$fileName', 			 				             '$fileSize', '$fileType', '$content', '$user', '$descrip', '$trade', '$picname')";        
$result = mysql_query($query)or die (mysql_error());
    
unset($_SESSION['uploaderror']);
$_SESSION['uploadcomplete'] = "Your picture was uploaded to our system.";
    header("location: http://www.***********.com");
    exit();
}	
?>

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.