Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I upload a file and it's description together, in one shot? 2

Status
Not open for further replies.

aalmeida

MIS
Aug 31, 2000
468
US
All,

I'm able to upload a file and latter insert a description to this file in my database but when I attempt to upload the file and it's description on the same form it fails to send the file posting only the description.

Is there a way to make it possible for the same form to post the file and the description?

thanks.

AL Almeida
CIO
May all those that come behind us, find us faithful.
 
There should be no interference between them.

Of course without any code its hard to say what may be causing the interference.

Post the relevant code and HTML form so we can take a look.





----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Ok! here it goes the name of this file is: adicionar-imoveis.php
Code:
<?php require_once('../Connections/ajmedia.php'); ?>
<?php
if (session_id()=='') {
  	session_start();
  	$_SESSION['_ownerID'] = '';
	$_SESSION['_propID'] = '';
} else{
	$_SESSION['_ownerID'] = '';
	$_SESSION['_propID'] = '';
}?>
<?php

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  //to fully log out a visitor we need to clear the session varialbles
  $_SESSION['MM_Username'] = NULL;
  $_SESSION['MM_UserGroup'] = NULL;
  $_SESSION['PrevUrl'] = NULL;
  unset($_SESSION['MM_Username']);
  unset($_SESSION['MM_UserGroup']);
  unset($_SESSION['PrevUrl']);
	
  $logoutGoTo = "index.php";
  if ($logoutGoTo) {
    header("Location: $logoutGoTo");
    exit;
  }
}
?>
<?php
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && true) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "index.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) 
  $MM_referrer .= "?" . $QUERY_STRING;
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
	
	function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") {
	  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
	
	  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
	
	  switch ($theType) {
	    case "text":
	      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
	      break;    
	    case "long":
	    case "int":
	      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
	      break;
	    case "double":
	      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
	      break;
	    case "date":
	      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
	      break;
	    case "defined":
	      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
	      break;
	  }
	  return $theValue;
   }

}
if (!function_exists("mkdir_recursive")) {
	function mkdir_recursive($pathname, $mode){
    	is_dir(dirname($pathname)) || mkdir_recursive(dirname($pathname), $mode);
    	return is_dir($pathname) || @mkdir($pathname, $mode);
	}
}
//var_dump($_POST); 
$compid_rs_tipodoimovel = "8";
if (isset($_SESSION['_compID'])) {
  $compid_rs_tipodoimovel = $_SESSION['_compID'];
}
mysql_select_db($database_ajmedia, $ajmedia);
$query_rs_tipodoimovel = sprintf("SELECT p_typ_id, p_typ_name, p_typ_desc FROM tbl_p_typ WHERE comp_id = %s", GetSQLValueString($compid_rs_tipodoimovel, "int"));
$rs_tipodoimovel = mysql_query($query_rs_tipodoimovel, $ajmedia) or die(mysql_error());
$row_rs_tipodoimovel = mysql_fetch_assoc($rs_tipodoimovel);
$totalRows_rs_tipodoimovel = mysql_num_rows($rs_tipodoimovel);

$compid_rs_tiponegocio = "8";
if (isset($_SESSION['_compID'])) {
  $compid_rs_tiponegocio = $_SESSION['_compID'];
}
mysql_select_db($database_ajmedia, $ajmedia);
$query_rs_tiponegocio = sprintf("SELECT tbl_b_typ, b_typ_name, b_typ_desc FROM tbl_b_typ WHERE comp_id = %s", GetSQLValueString($compid_rs_tiponegocio, "int"));
$rs_tiponegocio = mysql_query($query_rs_tiponegocio, $ajmedia) or die(mysql_error());
$row_rs_tiponegocio = mysql_fetch_assoc($rs_tiponegocio);
$totalRows_rs_tiponegocio = mysql_num_rows($rs_tiponegocio);

mysql_select_db($database_ajmedia, $ajmedia);
$query_rs_unit = "SELECT tbl_area_unity.unityid, tbl_area_unity.unity_symbol, tbl_area_unity.Unity_Name FROM tbl_area_unity";
$rs_unit = mysql_query($query_rs_unit, $ajmedia) or die(mysql_error());
$row_rs_unit = mysql_fetch_assoc($rs_unit);
$totalRows_rs_unit = mysql_num_rows($rs_unit);

mysql_select_db($database_ajmedia, $ajmedia);
$query_rs_money_type = "SELECT tbl_currency.currencyid, tbl_currency.currency_symbol, tbl_currency.currency_name FROM tbl_currency";
$rs_money_type = mysql_query($query_rs_money_type, $ajmedia) or die(mysql_error());
$row_rs_money_type = mysql_fetch_assoc($rs_money_type);
$totalRows_rs_money_type = mysql_num_rows($rs_money_type);

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "cadastro_imovel")) {
  $insertSQL = sprintf("INSERT INTO tbl_owner_info (comp_id, o_name) VALUES (%s, %s)",
  					   GetSQLValueString($_SESSION['_compID'], "text"),
                       GetSQLValueString($_POST['owner_name'], "text"));

  mysql_select_db($database_ajmedia, $ajmedia);
  $Result = mysql_query($insertSQL, $ajmedia) or die(mysql_error());
  $LastOwnerID = mysql_insert_id();
/*
 * If successfuly insert the new owner proceed inserting the property details
 * If successfuly inseted the propertydetail proceed inserting the autoreply if specifyed
 * and insert the movie/image in case of an image process it
 */
if ((isset($LastOwnerID)) && ($LastOwnerID != 0)) {
  $_SESSION['_ownerID'] = $LastOwnerID;
  $insertSQL = sprintf("INSERT INTO tbl_property_info (comp_id, owner_id, p_shortname, p_street_1, p_county, p_city, p_state, p_zip, p_typ, p_b_typ, p_area, p_unity, p_price, p_currency, p_description, payment_options) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_SESSION['_compID'], "text"),
                       GetSQLValueString($_SESSION['_ownerID'], "text"),
                       GetSQLValueString($_POST['p_shortname'], "text"),
                       GetSQLValueString($_POST['p_street_1'], "text"),
                       GetSQLValueString($_POST['p_county'], "text"),
                       GetSQLValueString($_POST['city'], "text"),
                       GetSQLValueString($_POST['state'], "text"),
                       GetSQLValueString($_POST['zip'], "text"),
                       GetSQLValueString($_POST['p_typ'], "int"),
                       GetSQLValueString($_POST['p_b_typ'], "int"),
                       GetSQLValueString($_POST['p_area'], "text"),
                       GetSQLValueString($_POST['a_unit'], "text"),
                       GetSQLValueString($_POST['p_price'], "text"),
                       GetSQLValueString($_POST['p_currency'], "text"),
                       GetSQLValueString($_POST['p_description'], "text"),
                       GetSQLValueString($_POST['b_options'], "text"));

  mysql_select_db($database_ajmedia, $ajmedia);
  $Result1 = mysql_query($insertSQL, $ajmedia) or die(mysql_error());
  $LastPropID = mysql_insert_id();
  
  if ((isset($LastPropID)) && ($LastPropID != 0)) {
  $_SESSION['_propID'] = $LastPropID;
  if ((isset($_POST['p_autoreplay'])) && ($_POST['p_autoreplay'] != '')) {
  $insertSQL = sprintf("INSERT INTO tbl_autoreplay (comp_id, prop_id, owner_id, content) VALUES (%s, %s, %s, %s)",
    	GetSQLValueString($_SESSION['_compID'], "int"),
    	GetSQLValueString($_SESSION['_propID'], "int"),
    	GetSQLValueString($_SESSION['_ownerID'], "int"),
    	GetSQLValueString($_POST['p_autoreplay'], "text"));    	
   //echo $insertSQL;
   mysql_select_db($database_ajmedia, $ajmedia);
   $Result2 = mysql_query($insertSQL, $ajmedia)or die(mysql_error());
   }
}else{//Property ID failure
  	if (!$LastPropID){
  		echo 'Resultado da query: '.$Result1.'<br/>'.'Owner ID: No ID';
  	    exit;
  	}else{
  		echo 'Resultado da query: '.$Result1.'<br/>'.'Owner ID: '.$LastPropID;
  		exit;
  	    }  	
    }
	/*
    * Now seting up the folder for the images 
    * and copy the slide show.
    */
   include_once('lib/files/copyDir.php');
   $cp = new copyDir();   
   $DirFrom = $_SESSION['_comp_url'].'slideshow';
   $DirTo = $_SESSION['_comp_images'].'pictures/'.$_SESSION['_compID'].'/'.$_SESSION['_ownerID'].'/'.$_SESSION['_propID'];
   /* debuging info
    * echo 'Copy php files <br/>';
    * echo $DirFrom.' <br/>';
    * echo $DirTo.' <br/>';
   */
   // set the directory to copy
   $cp->setCopyFromDir($DirFrom);
   // Create the directory and set the right permission	
   mkdir_recursive($DirTo, 0755);
   // set the directory to copy to
   $cp->setCopyToDir($DirTo);
   // copy also the image folder and it's content.
   // TODO: this needs to be tested to make sure it gives the correct permissions and copied all the files inside the images folder as well
   $cp->copySubFolders(false);
   // copy files
   $cp->createCopy(true);
   // Now copy the image folder
   $DirFromI = $DirFrom.'/images';
   $DirToI = $DirTo.'/images';
    /* debuging info
   	* echo 'Copy php files <br/>';
   	* echo $DirFrom.' <br/>';
   	* echo $DirTo.' <br/>';
	*/
   $cp->setCopyFromDir($DirFromI);
   $cp->setCopyToDir($DirToI, 0755);
   $cp->copySubFolders(false);
   $cp->createCopy(true);
/*
    * If a movie is specified insert values on tbl_p_pic 
    * elseif a pictures is provided upload the image and process it then insert the values on tbl_p_pic
    * If non is provided continue...
    */
   if ((isset($_POST['movie'])) && ($_POST['movie'] != '')) {
   	$insertSQL = sprintf("INSERT INTO tbl_p_pic (comp_id, owner_id, prop_id, pic_name, pic_typ, pic_url) VALUES (%s, %s, %s, %s, %s, %s)",
    	GetSQLValueString($_SESSION['_compID'], "int"),
    	GetSQLValueString($LastOnerID, "int"),
    	GetSQLValueString($LastPropID, "int"),
    	GetSQLValueString($_POST['movie'], "text"),
    	GetSQLValueString('video', "text"),
    	GetSQLValueString($_POST['movie'], "text"));    	
   //echo $insertSQL;
   mysql_select_db($database_ajmedia, $ajmedia);
   $Result3 = mysql_query($insertSQL, $ajmedia)or die(mysql_error());
   }elseif ((isset($_POST['uploadedfile'])) && ($_POST['uploadedfile'] != '')){
   	ini_set("memory_limit", "40M");
	include_once('lib/upload/upload.php');
	
	$sfiles = array();	
		foreach ($_FILES['uploadedfile'] as $k => $l) {
	    	foreach ($l as $i => $v) {
	        	if (!array_key_exists($i, $sfiles)) {
	            	$sfiles[$i] = array();
				}
	            $sfiles[$i][$k] = $v;
	        }
	    }
	 
	// now we can loop through each $files, and feed each element to the class
	/*
	 * The program flows like this
	 * 1)Upload and resize Thumbnail to thumbnails folder;
	 * 2)Upload the actual image to photos folder;
	 * 3)Insert image info into the DB;
	 * 4)Redirect to success.
	 */

    foreach ($sfiles as $file){    	
		
    	// we instanciate the class for each element of $file
    	// we use the Brazilian Portuguese messages.
        $handle = new Upload($file, 'pt_BR');
        // First upload the thumbnails
		if ($handle->uploaded) {
			// now, we start the upload 'process'. That is, to copy the uploaded file 
            // from its temporary location to the thumb's location
            // It could be something like $handle->Process('/home/[URL unfurl="true"]www/my_uploads/');[/URL]
            /*
       		 * Set variables to resize image to the thumbnails size
       		*/
            $target_thumb_path = $DirTo.'/thumbnails';
            //echo '$target_thumb_path = '.$target_thumb_path.'<br/>';
            $handle->image_resize           = true;
        	$handle->image_x           		= 125;
        	$handle->image_y                = 75;
        	// this line does the actual upload and resizing actions.
			$handle->Process(stripslashes($target_thumb_path));
			/*
       		 * Set variables to resize image to the full size
       		*/
			$target_path = $DirTo.'/photos';
			//echo '$target_path = '.$target_path.'<br/>';
			$handle->image_resize           = true;
			$handle->image_x           		= 640;
			$handle->image_y                = 480;
			$handle->Process(stripslashes($target_path));
			if ($handle->processed) { // If Thumbnail successfully uploaded than start processing the main image
						$insertSQL = sprintf("INSERT INTO tbl_p_pic (comp_id, owner_id, pic_typ, prop_id, pic_name, pic_url) VALUES (%s, %s, %s, %s, %s, %s)",
						   	GetSQLValueString($_SESSION['_compID'], "int"),
						   	GetSQLValueString($_SESSION['_ownerID'], "int"),
						   	GetSQLValueString('home', "text"),
						   	GetSQLValueString($_SESSION['_propID'], "text"),
						   	GetSQLValueString($handle->file_dst_name, "text"),				   	
						   	GetSQLValueString($handle->file_dst_name, "text"));
	
						mysql_select_db($database_ajmedia, $ajmedia);
						$Result4 = mysql_query($insertSQL, $ajmedia) or die(mysql_error());
						
						// $insertGoTo = "adicionar-fotos.php";						
						// if (isset($_SERVER['QUERY_STRING'])) { 
						// redirect to the main page everything was fine !
    					// $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    					// $insertGoTo .= $_SERVER['QUERY_STRING'];
						// next line for debug
 						// echo "The file ".  basename( $_FILES['uploadedfile']['name']). " has been uploaded to ".$target_path." and the info was entered into the DB."
 						
					// }	
					// End redirect to the main page everything was fine !
					echo $handle->log;
					exit; 
					// $handle->clean(stripslashes($target_thumb_path));
    				// $handle->clean(stripslashes($target_path));
    				// header(sprintf("Location: %s", $insertGoTo)); 						
				} else {
					
					// If Image isn't successfully uploaded than an error message should be returned.
					// next line for debug should be replaced by error handling procedure.
  					// TODO - There is the need for error handling here.
  					//echo $handle->log;
  					echo "There was an error uploading the file, the database was not updated, please try again! <br />";
					exit;
					}    	
    }
    //echo "<br/> File and it's description to upload are: <br />";
    //var_dump($file); 
    //echo '<br />';
    //var_dump($pic_desc); 
    $handle->clean(stripslashes($target_thumb_path));
    $handle->clean(stripslashes($target_path));
    echo $handle->log;
    exit;
    }
   } 
  }else{//owner ID failure
  	if (!$LastOnerID){
  		echo 'Resultado da query: '.$Result.'<br/>'.'Owner ID: No ID';
  	    exit;
  	}else{
  		echo 'Resultado da query: '.$Result.'<br/>'.'Owner ID: '.$LastOnerID;
  		exit;
  	    }  	
    }
  /*
   * All the processing is done and it is successful;
   * Now we can go to the next page to insert more images to the property
   */   
$insertGoTo = "adicionar-fotos.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
 }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?PHP echo 'Adicionar Imóveis ' . $_SESSION['_compname'];?></title>
<link href="css/imob.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>
<body onload="MM_preloadImages('images/nav-bar/inicial-down.png','images/nav-bar/adicionar-down.png','images/nav-bar/gerenciar-imovel-down.png','images/nav-bar/genrenciar-prop-down.png','images/nav-bar/relatorios-down.png','images/nav-bar/sair-down.png')">
<table width="1000" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td align="center" valign="top">
    <?PHP require_once('header.php'); ?>
    </td>
  </tr>
  <tr>
    <td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="35" align="center" valign="middle" bgcolor="#EDE9BA"><span class="subHeader2">ADICIONAR IMÓVEIS</span></td>
      </tr>
      <tr>
        <td height="50" align="center" valign="middle"><table width="900" border="0" cellpadding="2" cellspacing="0">
          <form action="adicionar-imoveis.php" method="post" name="cadastro_imovel" id="cadastro_imovel" enctype="multipart/form-data">
            <tr>
              <td height="50" colspan="9" align="center" valign="middle" nowrap="nowrap" class="bodystyle-medium-redbold"><font class="subHeader3">DADOS DO IM&Oacute;VEL</font>&nbsp;<br />
                OBS: Todos os campos em vermelho s&atilde;o obrigat&oacute;rios!</td>
            </tr>
            <tr>
              <td width="169" align="right" valign="top" nowrap="nowrap" class="bodystyle-medium-redbold">Nome do Propriet&aacute;rio:</td>
              <td colspan="8" align="left" valign="top" class="bodystyle-medium"><input name="owner_name" type="text" lang="pt" value="" size="60" maxlength="100" xml:lang="pt"/></td>
            </tr>
            <tr>
              <td align="right" valign="top" nowrap="nowrap" class="bodystyle-medium-redbold">Nome do Im&oacute;vel:</td>
              <td colspan="8" align="left" valign="top" class="bodystyle-medium"><input name="p_shortname" type="text" lang="pt" value="" size="60" maxlength="100" xml:lang="pt"/></td>
            </tr>
            <tr>
              <td align="right" valign="top" nowrap="nowrap" class="bodystyle-medium-redbold">Tipo de Im&oacute;vel:</td>
              <td colspan="8" align="left" valign="top" class="bodystyle-medium"><table width="96%" border="0" cellspacing="0" cellpadding="2">
                  <tr>
                    <td width="19%" align="left" valign="top"><select name="p_typ" class="bodystyle-medium" lang="pt" xml:lang="pt">
                      <option value="0">Selecione Aqui</option>
                      <?php
do {  
?>
                      <option value="<?php echo $row_rs_tipodoimovel['p_typ_id']?>"><?php echo $row_rs_tipodoimovel['p_typ_name']?></option>
                      <?php
} while ($row_rs_tipodoimovel = mysql_fetch_assoc($rs_tipodoimovel));
  $rows = mysql_num_rows($rs_tipodoimovel);
  if($rows > 0) {
      mysql_data_seek($rs_tipodoimovel, 0);
	  $row_rs_tipodoimovel = mysql_fetch_assoc($rs_tipodoimovel);
  }
?>
                    </select></td>
                    <td width="16%" align="right" valign="top" nowrap="nowrap" class="bodystyle-medium-redbold">Tipo de Neg&oacute;cio:</td>
                    <td width="65%"><select name="p_b_typ" class="bodystyle-medium" lang="pt" xml:lang="pt">
                      <option value="0" lang="pt" xml:lang="pt">Selecione Aqui</option>
                      <?php
do {  
?>
                      <option value="<?php echo $row_rs_tiponegocio['tbl_b_typ']?>"><?php echo $row_rs_tiponegocio['b_typ_name']?></option>
                      <?php
} while ($row_rs_tiponegocio = mysql_fetch_assoc($rs_tiponegocio));
  $rows = mysql_num_rows($rs_tiponegocio);
  if($rows > 0) {
      mysql_data_seek($rs_tiponegocio, 0);
	  $row_rs_tiponegocio = mysql_fetch_assoc($rs_tiponegocio);
  }
?>
                    </select></td>
                  </tr>
              </table></td>
            </tr>
            <tr>
              <td align="right" valign="top" nowrap="nowrap" class="formText">Endere&ccedil;o:</td>
              <td colspan="8" align="left" valign="top" class="bodystyle-medium"><input name="p_street_1" type="text" lang="pt" size="60" maxlength="100" xml:lang="pt"/></td>
            </tr>
            <tr>
              <td align="right" valign="top" nowrap="nowrap" class="formText">Bairro: </td>
              <td width="99" align="left" valign="top" class="bodystyle-medium"><input name="p_county" type="text" lang="pt" size="15" maxlength="100" xml:lang="pt"/></td>
              <td width="58" align="right" valign="top" class="formText">Cidade:</td>
              <td width="135" align="left" valign="top" class="bodystyle-medium"><input name="city" type="text" lang="pt" size="20" maxlength="100" xml:lang="pt"/></td>
              <td width="67" align="right" valign="top" class="formText">Estado:</td>
              <td width="136" align="left" valign="top" class="bodystyle-medium"><input name="state" type="text" lang="pt" size="20" maxlength="100" xml:lang="pt"/></td>
              <td width="26" align="right" valign="top" class="formText">CEP:</td>
              <td width="178" colspan="2" align="left" valign="top" class="bodystyle-medium"><input name="zip" type="text" lang="pt" size="15" maxlength="100" xml:lang="pt"/></td>
            </tr>
            <tr>
              <td align="right" valign="top" nowrap="nowrap" class="formText">&Aacute;rea Total: </td>
              <td colspan="8" align="left" valign="top" nowrap="nowrap" class="bodystyle-medium"><input name="p_area" type="text" lang="pt" size="40" maxlength="50" xml:lang="pt" />
                  <label class="bodystyle-medium"><span class="formText">Un. de &Aacute;rea:</span>
                  <select name="a_unit" class="bodystyle-medium">
                    <?php
do {  
?>
                    <option value="<?php echo $row_rs_unit['unityid']?>"><?php echo $row_rs_unit['unity_symbol']?></option>
                    <?php
} while ($row_rs_unit = mysql_fetch_assoc($rs_unit));
  $rows = mysql_num_rows($rs_unit);
  if($rows > 0) {
      mysql_data_seek($rs_unit, 0);
	  $row_rs_unit = mysql_fetch_assoc($rs_unit);
  }
?>
                  </select>
                  </label>              </td>
            </tr>
            <tr>
              <td align="right" valign="top" nowrap="nowrap" class="bodystyle-medium-redbold">Valor:</td>
              <td colspan="8" align="left" valign="top" nowrap="nowrap" class="bodystyle-medium"><input name="p_price" type="text" lang="pt" size="30" maxlength="50" xml:lang="pt" />
                  <label class="bodystyle-medium"><span class="bodystyle-medium-redbold">Un. Monet&aacute;ria: </span>
                  <select name="p_currency" class="bodystyle-medium" lang="pt" xml:lang="pt">
                    <?php
do {  
?>
                    <option value="<?php echo $row_rs_money_type['currencyid']?>"><?php echo $row_rs_money_type['currency_symbol']?></option>
                    <?php
} while ($row_rs_money_type = mysql_fetch_assoc($rs_money_type));
  $rows = mysql_num_rows($rs_money_type);
  if($rows > 0) {
      mysql_data_seek($rs_money_type, 0);
	  $row_rs_money_type = mysql_fetch_assoc($rs_money_type);
  }
?>
                  </select>
                  </label>              </td>
            </tr>
            <tr>
              <td align="right" valign="top" nowrap="nowrap" class="formText">Op&ccedil;&otilde;es de Negocia&ccedil;&atilde;o:</td>
              <td colspan="8" align="left" valign="top" nowrap="nowrap" class="bodystyle-medium"><textarea name="b_options" cols="50" rows="3" wrap="physical" lang="pt" xml:lang="pt"></textarea></td>
            </tr>
            <tr>
              <td align="right" valign="top" nowrap="nowrap" class="bodystyle-medium-redbold">Descri&ccedil;&atilde;o:</td>
              <td colspan="8" align="left" valign="top" class="bodystyle-medium"><textarea name="p_description" cols="80" rows="10" lang="pt" xml:lang="pt"></textarea></td>
            </tr>
            <tr>
              <td align="right" valign="top" nowrap="nowrap" class="formText">Resposta Autom&aacute;tica:</td>
              <td colspan="8" align="left" valign="top" class="bodystyle-medium"><textarea name="p_autoreplay" cols="80" rows="10" lang="pt" xml:lang="pt"></textarea></td>
            </tr>
            <tr>
              <td colspan="9" align="left" valign="top" nowrap="nowrap" class="formText"><table width="900" border="0" cellspacing="0" cellpadding="2">
            <tr>
               <td colspan="4" align="center" valign="top" nowrap="nowrap" class="formText">OBS: Escolha uma foto de destaque OU um filme do You Tube. Se um filme for inserido, ele sempre ser&aacute; o destaque e a foto ser&aacute; ignorada.</td>
                  </tr>
            <tr>
                  <td width="166" align="right" valign="top" nowrap="nowrap" class="formText"> Foto Destaque:</td>
                  <td width="256" align="left" valign="top" nowrap="nowrap"><input name="uploadedfile" type="file" value=""/></td>
                  <td width="203" align="right" valign="top" nowrap="nowrap" class="formText">Nome do Filme no YouTube:</td>
                  <td width="259" align="left" valign="top" nowrap="nowrap"><span class="bodystyle">
                    <input type="text"   name="movie" value=""/>
                    <input name="Submit" type="submit" class="bodystyle-medium" id="Adicionar" value="IR" />
                  </span></td>
                </tr>
                <tr>
                  <td height="40" colspan="4" align="center" valign="middle"><input type="submit" name="Submit2" value="Cadastrar"/>
                    &nbsp;
                    <input name="Reset" type="reset" id="Reset" value="Limpar" /></td>
                  </tr>
              </table></td>
              </tr>
            <input type="hidden" name="MM_insert" value="cadastro_imovel" />
          </form>
        </table>
          </td>
      </tr>
    </table></td>
  </tr>
  <tr>
 <td align="center" valign="top"><img src="images/admin_footer.png" width="1000" height="50" /></td>
  </tr>
</table>
</body>
</html>
<?php
if (isset($rs_tipodoimovel)) {
	mysql_free_result($rs_tipodoimovel);
}
if (isset($rs_tiponegocio)) {
	mysql_free_result($rs_tiponegocio);
}
if (isset($rs_unit)) {
	mysql_free_result($rs_unit);
}
if (isset($rs_money_type)) {
	mysql_free_result($rs_money_type);
}
?>

If you feel it necessary, I can also send you the upload and CopyDir classes but it seems to me that the upload class is never initiated because the $_POST[uploadedfile] is empty; therefore, the elseif on line 256 bypasses the upload all together. Let me know your thoughts.
Thanks,

AL Almeida
CIO
May all those that come behind us, find us faithful.
 
without wading through the awful dreamweaver generated code to upload description and file at the same time is an html + http issue. not a php issue.

this form will be fine, for example

Code:
<form method="post" enctype="multipart/form-data" />
<input type="file" name="uploadFile" /><br/>
<input type="text" name="description" value="" /> Description<br/>
<input type="submit" name="submit" value="Upload" />
</form>

then your receiving script will be able to use the data in $_FILES and $_POST['description'].

 
I did specify "relevant code". There's much more there than what we would really need.

Do you get errors? How are you adding the description field? how are you attempting to use it in the query? I don't see a description field anywhere but of course its very hard to see anything in that mess of code.

Are you sure the file is not getting through?

With all that said jpadie's excellent form, is a good starting point.


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Ok!
Sorry for the dreamweaver code but there is not much I can do about it may be Adobe would like to improve on it for future version.
jpadie, gave me a good pointer with the form, when I went back to the code today after reading he's post I found the issue it was caused by the elseif that was looking for the file on the $_POST instead of $_FILE bypassing the upload code altogether.

Phil AKA Vacunita, Sorry I gave to much information there, yes you did ask for the relevant code, I was caught by surprise by the fast replay (I was on my way to bed already when I send the post LOL )I tried to point out the problematic code providing the line number.
Once again I appreciate you all effort in helping, I'll do my best to be more direct next time.

thanks,

AL Almeida
CIO
May all those that come behind us, find us faithful.
 
Its o.k. Its just that so much code can make it hard to debug things. With that said, I should have picked up on the $_POST['uploadedfile'] bit.

But somehow it slipped by.


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top