Jump to content

Image Upload


sblake161189

Recommended Posts

Hi Guys!  :)

 

I already have a database with a table that stores information about different franchises for the company like franchise name, address, tel, email etc etc. This works beautiful so I can CRUD this data.

 

However, now to be able to add the facility for each franchise to be able to upload their own image of the franchise itself and still be able to CRUD the data.

 

I have looked on the internet and found many scripts using BLOB etc but I can get it to link in with my existing table.

 

I'll show you the edit form that I have so far. (Pleas not Ter = territory, ie the territory that franchise covers.

 

<?php
include('config.php'); 
if (isset($_GET['Ter']) ) { 
$ter = (int) $_GET['Ter']; 
if (isset($_POST['submitted'])) { 
foreach($_POST AS $key => $value) { $_POST[$key] = mysql_real_escape_string($value); } 
$sql= "UPDATE `ter` SET `Ter` =  '{$_POST['Ter']}' , `BranchName` = '{$_POST['BranchName']}' ,  `BranchAddress` =  '{$_POST['BranchAddress']}' ,  `BranchTel` =  '{$_POST['BranchTel']}' , `BranchEmail` =  '{$_POST['BranchEmail']}' , `BranchLink` =  '{$_POST['BranchLink']}' , `Theme` =  '{$_POST['Theme']}' , `LocalInfo` =  '{$_POST['LocalInfo']}' , `BranchInfo` =  '{$_POST['BranchInfo']}' WHERE `Ter` = '$ter' "; 
mysql_query($sql) or die(mysql_error()); 
echo (mysql_affected_rows()) ? "Edited Branch.<br />" : "Nothing changed. <br />";  
} 
$row = mysql_fetch_array ( mysql_query("SELECT * FROM `ter` WHERE `Ter` = '$ter' "));
?>

<form action='' method='POST'> 
<p><b>Territory:</b><br /><input name='Ter' type='text' value='<?= stripslashes($row['Ter']) ?>' size="3" readonly="readonly" />
<p><b>Branch Name:</b><br /><input name='BranchName' type='text' value='<?= stripslashes($row['BranchName']) ?>' size="50" /> 
<p><b>Address:</b><br />
  <textarea name='BranchAddress' cols="40" rows="5"><?= stripslashes($row['BranchAddress']) ?></textarea> 
<p><b>Telephone:</b><br /><input name='BranchTel' type='text' value='<?= stripslashes($row['BranchTel']) ?>' size="15" />
<p><b>Email:</b><br /><input name='BranchEmail' type='text' value='<?= stripslashes($row['BranchEmail']) ?>' size="50" />
<p><b>Link:</b><br /><input name='BranchLink' type='text' value='<?= stripslashes($row['BranchLink']) ?>' size="50" />
<hr />
<p><b>Your Single Webpage Options</b>
<p><b>Theme:</b><br />
  <input name='Theme' type='text' value='<?= stripslashes($row['Theme']) ?>' size="1" />
<p><b>Local Information:</b><br />
  <textarea name='LocalInfo' cols="85" rows="8" id="LocalInfo"><?= stripslashes($row['LocalInfo']) ?>
  </textarea>
<p><b>Franchise Information:</b><br />
  <textarea name='BranchInfo' cols="85" rows="8" id="BranchInfo"><?= stripslashes($row['BranchInfo']) ?>
  </textarea>
<p><b>Photo:</b><br />
  <label>
    <input type="file" name="photo" id="photo" />
  </label> 
  (Franchise Photo)  
<p><b>Downloads:</b><br />
  <label>
    <input type="file" name="download1" id="download1" />
  </label> 
  (S/O Mandate)
<p>
  <label>
    <input type="file" name="download2" id="download2" />
  </label>
  (Other Download)
<p>
  <label>
    <input type="file" name="download3" id="download3" />
  </label>
  (Other Download)
<p>
  <input type='submit' value='Save' />
  <input type='hidden' value='1' name='submitted' />
</form>

<? } ?>

 

It is the 'photo' file above that I want to be able to upload the image with. Is this the right way to do it?

 

Ignore the download1,2,3 bit.

 

Cheers, S

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.