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();
}	
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.