Jump to content

display uploaded photos?


andy_b_1502

Recommended Posts

My photo files are not being displayed in my table?

 

They get sent to the mySQL database, then the server and it does grab all the other variables in the table and displays them, but the .jpg's are not shown, instead theres just the file name??

 

<?php 
error_reporting(E_ALL);
ini_set("display_errors", 1);
echo '<pre>' . print_r($_FILES, true) . '</pre>';


//This is the directory where images will be saved 
$target = "/home/users/web/b109/ipg.removalspacecom/images/COMPANIES"; 
$target = $target . basename( $_FILES['upload']['name']); 

//This gets all the other information from the form 
$company_name=$_POST['company_name']; 
$basicpackage_description=$_POST['basicpackage_description']; 
$location=$_POST['location']; 
$postcode=$_POST['postcode'];
$upload=($_FILES['upload']['name']); 

// Connects to your Database 
mysql_connect("server****", "username***", "password****") or die(mysql_error()) ; 
mysql_select_db("DB") or die(mysql_error()) ; 

//Writes the information to the database 
mysql_query("INSERT INTO `Companies` (company_name, basicpackage_description, location, postcode,  upload) VALUES ('$company_name', '$basicpackage_description', '$location', '$postcode',  '$upload')") ; 
echo mysql_error();

//Writes the photo to the server 
if(move_uploaded_file($_FILES['upload']['tmp_name'], $target)) 
{ 

//Tells you if its all ok 
echo "The file ". basename( $_FILES['upload']['name']). " has been uploaded, and your information has been added to the directory"; 
} 
else { 

//Gives and error if its not 
echo "Sorry, there was a problem uploading your file."; 
} 
?> 

 

"upload" is the variable that isnt displaying in my table how i want it to? Have you guys any ideas how to get it displayed correctly?

Link to comment
Share on other sites

i have this so far, it shows all of the table, which is what i want all except the images

 

i've had a look for a possible answer and added the path to the image folder on my server but it doesn't seem to work, how can i get this to show the images from the folder on the server?

 

 

<?php 
// Make a MySQL Connection 
mysql_connect("server", "user", "password") or die(mysql_error()); 
mysql_select_db("my_DB") or die(mysql_error()); 

// Retrieve all the data from the "example" table 
$result = mysql_query("SELECT company_name, location, postcode, basicpackage_description, premiumuser_description, upload FROM Companies") 
or die(mysql_error());   

// store the records of the "TABLENAME" table into $row array and loop through 
while ( $row = mysql_fetch_array( $result, MYSQL_ASSOC ) ) { 

// Print out the contents of the entry  

echo "details: ".$row['details']; 
echo "<img src=\"/home/users/web/b109/ipg.removalspacecom/images/COMPANIES".$row['image1']."\" alt=\"name\" />"; 
} 
?> 

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.