Jump to content

Recommended Posts

I am building a website where people can post jobs that need to be done and have laborers bid on them.... Im done with pretty much everything on the site but im having a hard time figuring out how to upload and display multiple images for each job.... I am able to upload and display one image but i can upload multiple images.... Everytime I try to do so, It only displays multiple copies of the first image that i upload... The code is below.... Can anyone help me out??

 

This is the file for entering job info and uploading the images

{OVERALL_HEADER}
<SCRIPT LANGUAGE="JavaScript">
function formValidation(form)
{
if(notEmpty(form.project_name,"{LANG_PROJNAME}"))
{
	if(notEmpty(form.project_description,"{LANG_PROJDESC}"))
	{
		if(notEmpty(form.days,"{LANG_BIDTIME}"))
		{
			return true;
		}
	}
}
return false;
}
function notEmpty(elem,fname)
{
var str = elem.value;
if(str.length == 0)
{
	alert("You must fill in the "+fname+" field.");
	return false;
} 
else 
{
	return true;
}
}
</script>
<table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td valign="top">      <form onSubmit="return formValidation(this)" action="" method="post" enctype="multipart/form-data" name="form">
      {LOOP: ERRORS}<span class="error">- {ERRORS.message}</span><br>
      {/LOOP: ERRORS} <br>
      <table border="0" cellspacing="0" cellpadding="4" class="normal">
        <tr>
          <td><strong>{LANG_USERNAME}</strong></td>
        </tr>
        <tr>
          <td>{USERNAME}</td>
        </tr>
        <tr>
          <td><strong>{LANG_PROJNAME}</strong></td>
        </tr>
        <tr>
          <td><input name="project_name" type="text" id="project_name" size="40" maxlength="200" value="{PROJECTTITLE}"></td>
        </tr>
        <tr>
          <td><strong>{LANG_PROJTYPE}</strong></td>
        </tr>
        <tr>
          <td>
	  <table border="0" cellpadding="0" cellspacing="0">
	  {LOOP: JOBTYPES}
	  <tr><td><input name="jobtype[{JOBTYPES.id}]" type="checkbox" value="{JOBTYPES.id}"></td><td> {JOBTYPES.title}</td></tr>
	  {/LOOP: JOBTYPES}
	  </table>
	  </td>
        </tr>
        <tr>
          <td><strong>{LANG_DATABASE}</strong></td>
        </tr>
        <tr>
          <td><select name="dbtype" id="select3">
            <option value="({LANG_NONE})" selected>({LANG_NONE})</option>
            <option value="({LANG_PLEASESUGGEST})">({LANG_PLEASESUGGEST})</option>
            <option value="MySQL">MySQL</option>
            <option value="SQL">SQL</option>
            <option value="MSQL">MSQL</option>
            <option value="MS SQL">MS SQL</option>
            <option value="PostgreSQL">PostgreSQL</option>
            <option value="Oracle">Oracle</option>
            <option value="LDAP">LDAP</option>
            <option value="DBM">DBM</option>
          </select></td>
        </tr>
        <tr>
          <td><strong>{LANG_OPSYS}</strong></td>
        </tr>
        <tr>
          <td><select name="ostype" id="select4">
            <option selected>({LANG_DONTKNOW})</option>
            <option>Unix</option>
            <option>Linux</option>
            <option>Solaris</option>
            <option>Windows</option>
            <option>(Other)</option>
          </select></td>
        </tr>
        <tr>
          <td><strong>{LANG_PROJDESC}</strong></td>
        </tr>
        <tr>
          <td><textarea name="project_description" cols="50" rows="9" id="textarea">{DESCRIPTION}</textarea></td>
        </tr>
        <tr>
          <td><p><strong>{LANG_ATTACHMENT}:</strong>
              <input name="attachment" type="file" id="attachment2" size="40"> 
            (Max. 500 KB)<br />
            <strong>{LANG_ATTACHMENT}:</strong>
            <input name="attachment2" type="file" id="attachment" size="40" />
(Max. 500 KB)</p>
            </td>
        </tr>
        <tr>
          <td> </td>
        </tr>
        <tr>
          <td><strong>{LANG_BUDGET}</strong></td>
        </tr>
        <tr>
          <td>{LANG_MIN}: {CURRENCY_SIGN}
              <input name="budget_min" type="text" id="budget_min2" size="8" value="{MINBUDGET}"></td>
        </tr>
        <tr>
          <td>{LANG_MAX}: {CURRENCY_SIGN}
              <input name="budget_max" type="text" id="budget_max2" size="8" value="{MAXBUDGET}"></td>
        </tr>
        <tr>
          <td> </td>
        </tr>
        <tr>
          <td>{LANG_WANTBID} <input name="days" type="text" id="days2" size="5" maxlength="2" value="{BIDDINGTIME}"> {LANG_DAYS}</td>
        </tr>
        <tr>
          <td> </td>
        </tr>
        <tr>
          <td><input name="featured" {FEATURED} type="checkbox" id="featured2" value="1"> {LANG_WANTPAY} {CURRENCY_SIGN}{FEATURED_PRICE} {LANG_WANTFEAT}</td>
        </tr>
        <tr>
          <td> </td>
        </tr>
        <tr>
          <td><input type="submit" name="Submit" value="{LANG_SUBPROJECT}"></td>
        </tr>
      </table>
    </form>    <br>
    </td>
  </tr>
</table>
{OVERALL_FOOTER}

 

Attachment.php

<?php
require_once('includes/config.php');
require_once('includes/functions/func.global.php');

db_connect($config);

if(!isset($_GET['type']))
{
$_GET['type'] = 'attachment';
}

if($_GET['type'] == 'image')
{
$query = "SELECT provider_picture,provider_pictype FROM `".$config['db']['pre']."providers` WHERE provider_id='" . validate_input($_GET['id']) . "' LIMIT 1";
$query_result = @mysql_query ($query) OR error(mysql_error());
$rows = mysql_num_rows($query_result);

if($rows == 0)
{
	$filedata = base64_decode('R0lGODlhAQABAIAAAMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');
	$filesize = strlen($filedata);

	header('Content-type: image/gif');
	header('Content-Length: ' . $filesize);
	header('Connection: Close');

	echo $filedata;
	exit;
}
else
{
	while ($info = @mysql_fetch_array($query_result))
	{	
		if($info['provider_picture'] == '')
		{
			$filedata = base64_decode('R0lGODlhAQABAIAAAMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');
			$filesize = strlen($filedata);

			header('Content-type: image/gif');
			header('Content-Length: ' . $filesize);
			header('Connection: Close');

			echo $filedata;
			exit;
		}
		else
		{
			header("Content-type: " . $info['provider_pictype']);
			echo stripslashes($info['provider_picture']);
		}
	}
}
}
else
{
$query = "SELECT file_name,file_type,file_size,file_content FROM `".$config['db']['pre']."attachments` WHERE file_id='" . validate_input($_GET['id']) . "' LIMIT 1";
$query_result = @mysql_query ($query) OR error(mysql_error());
$rows = mysql_num_rows($query_result);

if($rows == 0)
{
	exit;
}
else
{
	while ($info = @mysql_fetch_array($query_result))
	{	
		header('Content-disposition: attachment; filename="' . $info['file_name'] . '"'); 
		header("Content-length: ".$info['file_size']);
		header('Content-type: ' . $info['file_type']);
		echo $info['file_content'];
		exit;
	}
}
}
?>

 

This is the page that displays the information.

{OVERALL_HEADER}<table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td valign="top"><br>
      <span class="project_title_header"> {LANG_PROJECT}:</span> <span class="project_title">{PROJECT_TITLE}</span><br>
      <span class="normal"><strong> {LANG_ID}:</strong> {PROJECT_ID}</span><br>
      <br>
      <table width="100%" border="0" cellpadding="4" cellspacing="3">
        <tr class="normal" bgcolor="#ECECEC" valign="top">
          <td width="180"><strong>{LANG_STATUS}: </strong></td>
          <td>{PROJECT_STATUS}</td>
        </tr>
        <tr class="normal">
          <td><strong>{LANG_BUDGET}: </strong></td>
          <td>{PROJECT_BUDGET}</td>
        </tr>
        <tr class="normal" bgcolor="#ECECEC" valign="top">
          <td><strong>{LANG_CREATED}:</strong></td>
          <td>{PROJECT_START_DATE} at {PROJECT_START_TIME} {PROJECT_START_TIMEZONE} </td>
        </tr>
        <tr class="normal">
          <td><strong>{LANG_BIDENDS}:</strong></td>
          <td>{PROJECT_END_DATE} at {PROJECT_END_TIME} {PROJECT_END_TIMEZONE} </td>
        </tr>
        <tr class="normal" bgcolor="#ECECEC" valign="top">
          <td><strong>{LANG_PROJCREATOR}:</strong></td>
          <td><a href="{SITE_URL}profile.php?id={PROJECT_CREATOR_ID}&type=buyer">{PROJECT_CREATOR_USERNAME}</a></td>
        </tr>
        <tr class="normal">
          <td><strong>{LANG_RATING}: </strong></td>
          <td>		  
	  IF("{REVIEWS}"=="0"){({LANG_NOFEEDYET}){:IF}
	  IF("{REVIEWS}"!="0"){<a href="{SITE_URL}reviews.php?id={PROJECT_CREATOR_ID}&type=buyers"><img border="0" src="{SITE_URL}templates/{TPL_NAME}/images/rating_{RATING}.gif"><br>({REVIEWS} {LANG_REVIEWS})</a>{:IF}		  </td>
        </tr>
        <tr class="normal" bgcolor="#ECECEC" valign="top">
          <td><strong>{LANG_DESC}:</strong></td>
          <td> {PROJECT_DESC}</td>
        </tr>
        IF("{ATTACHMENT}" == "1"){<tr class="normal" valign="top"><td><strong>{LANG_ATTACHMENT}:</strong></td><td><a href="attachment.php?id={FILE_ID}"><img src="attachment.php?id={FILE_ID}"><a href="attachment.php?id={FILE_ID}"><img src="attachment.php?id={FILE_ID}"></a></td></tr>{:IF}
        <tr class="normal" IF("{ATTACHMENT}" == "1"){bgcolor="#ECECEC"{:IF} valign="top">
          <td><strong>{LANG_JOBTYPE}: </strong></td>
          <td> {LOOP: PROJECT_TYPES}- {PROJECT_TYPES.name}<br>
    {/LOOP: PROJECT_TYPES} </td>
        </tr>
      </table>
      <br>      <br>
      <span class="normal"><a href="{SITE_URL}board.php?i={PROJECT_ID}">{LANG_VIEWMSGB}</a><br>
{LANG_MESSPOSTED}: <strong>{MESSAGES}</strong></span><br>
<br><br>
<table width="780" cellpadding="0" cellspacing="1" border="0">
  <tr>
    <td colspan="5"> 
IF("{PROJECT_STATUS2}"=="open"){<a href="{SITE_URL}bid.php?id={PROJECT_ID}"><img src="{SITE_URL}templates/{TPL_NAME}/images/button_placebid.gif" width="76" height="16" alt="" border="0"></a><br><br>{:IF}
IF("{EDIT_BID}"=="1"){<a href="{SITE_URL}bid.php?id={PROJECT_ID}"><img src="{SITE_URL}templates/{TPL_NAME}/images/edit_bid.gif" width="76" height="16" alt="" border="0"></a><br><br>{:IF}
</td>
  </tr>
  <tr class="normal" bgcolor="#E1E1E1" align="center">
    <td width="300" align="left"><strong>{LANG_PROVIDERU}</strong></td>
    <td width="60"><div align="center"><strong>{LANG_BID}</strong></div></td>
    <td width="100"><div align="center"><strong>{LANG_DELWITHIN}</strong></div></td>
    <td width="136"><strong>{LANG_TIMEOFBID}</strong></td>
    <td width="136"><strong>{LANG_RATING}</strong></td>
  </tr>
  {LOOP: BIDS}
  <tr class="normal">
    <td><a href="{SITE_URL}profile.php?id={BIDS.user_id}&type=provider">{BIDS.username}</a></td>
    <td>{CURRENCY_SIGN}{BIDS.bid_amount}</td>
    <td>{BIDS.bid_days} {LANG_DAYSB}</td>
    <td>{BIDS.bid_date} {LANG_AT} {BIDS.bid_time} {BIDS.bid_timezone}</td>
    <td><div align="center">
	IF("{BIDS.bid_reviews}"=="0"){({LANG_NOFEEDYET}){:IF}
	IF("{BIDS.bid_reviews}"!="0"){<a href="{SITE_URL}reviews.php?id={BIDS.user_id}&type=provider"><img border="0" src="{SITE_URL}templates/{TPL_NAME}/images/rating_{BIDS.bid_rating}.gif"><br>({BIDS.bid_reviews} {LANG_REVIEWS})</a>{:IF}  
</div></td>
  </tr>
  <tr class="normal">
    <td colspan="5">{BIDS.bid_desc}</td>
  </tr>
  <tr>
    <Td colspan="5" height="1" background="{SITE_URL}templates/{TPL_NAME}/images/hline_dot.gif"></TD>
  </tr>
  {/LOOP: BIDS}
  <tr>
    <td colspan="5"><br>
IF("{PROJECT_STATUS2}"=="open"){<a href="{SITE_URL}bid.php?id={PROJECT_ID}"><img src="{SITE_URL}templates/{TPL_NAME}/images/button_placebid.gif" width="76" height="16" alt="" border="0"></a><br><br>{:IF}
IF("{EDIT_BID}"=="1"){<a href="{SITE_URL}bid.php?id={PROJECT_ID}"><img src="{SITE_URL}templates/{TPL_NAME}/images/edit_bid.gif" width="76" height="16" alt="" border="0"></a><br><br>{:IF}
</td>
  </tr>
</table>
<br></td>
  </tr>
</table>
{OVERALL_FOOTER}

Link to comment
https://forums.phpfreaks.com/topic/68123-uploading-and-displaying-multiple-images/
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.