Page 1 of 1

File Uploading Problem

Posted: Mon Jun 15, 2009 8:06 am
by kalpesh
hi
I try to upload multiple files in different folders.
Here is my full code where i enter different banner in every city and that banner goes to that city banner folder.

Code: Select all

 
<?php
if(isset($_POST['submit']))
{
    function quote_smart($value){
     // Stripslashes
     if (get_magic_quotes_gpc()) {
       $value = stripslashes($value);
     }
     // Quote if not a number or a numeric string
     if (!is_numeric($value)) {
       $value = mysql_real_escape_string($value) ;
     }
     return $value;
    }
 
$detail = $_POST['detail'];
  $CategoryBanner=$_POST['CategoryBanner'];
    $city=$_POST['City'];
    $detail=$_POST['detail'];
   $count=count($city);
     $int=ceil($count/2);
        $today =date("Y-m-d");
        
          $count=count($city);
 
 
   for($i='0';$i<$count;$i++)
    {
        echo $city[$i].",".$CategoryBanner[$i].",".$detail[$i]."<br />";
                    $banner1=$_FILES['CategoryBanner']['name'][$i];
                $banner='';
                $bannername="Banner_".$city[$i];
                $oldbannername="Old_Banner_".$city[$i];
                if(is_dir("../../banner/")){
                                if(strlen($_FILES['CategoryBanner']['name'][$i])>0){
                                    $CategoryBanner = $_FILES['CategoryBanner']['name'][$i];
copy($_FILES['CategoryBanner']['tmp_name'][$i],"../../banner/".$bannername."/".$CategoryBanner) or die("Could not Upload") ;
                                        $banner = $CategoryBanner;
                                         }
                                }
                
    }
?>
  <script language="javascript">
      <!-- window.close();-->
     </script>
     <?php
}
                 /* End: Here Add coding for Panel Page */
    ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>::Kalpesh::</title>
<script language="javascript" type="text/javascript">
function validation() {
    if ( document.f3.aemake.value=="")
    {   alert("Please Select a Category !");
    document.f3.aemake.focus();
        return false;
    }
     if ( document.f3.subcataName.value=="")
    {   alert("Select a Sub-Category !");
    document.f3.aemake.focus();
        return false;
    }
    if ( document.f3.aemodel.value=="")
    {   alert("Select Product !");
        return false;
    }
    if ( document.f3.CityName.value=="")
    {   alert("Select City !");
        return false;
    }
    return true;
}
function cool(hot){
//alert(hot);
document.f3.sub.value=hot;
}
function product(hot){
//alert(hot);
document.f3.pro.value=hot;
}
 
</script>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/core.js"></script>
</head>
<body>
<div id="midlepanel"><div id="page_cont"><table width="100%" border="0" cellspacing="0" cellpadding="0">
    <form action="Edit.php" method="post" name="f3" >
 <tr>
            <td align="right" valign="top">&nbsp;</td>
            <td align="left">&nbsp;</td>
          </tr>
          <tr>
            <td width="25%" align="right" valign="top">&nbsp;</td>
            <td width="75%" align="left" style="Font-size:11px;">&nbsp;<?php echo $Result;?></td>
          </tr>
          <tr>
            <td valign="top" align="right">&nbsp;</td>
            <td align="left">&nbsp;</td>
            </tr>
           <tr>
            <td valign="top" align="right">&nbsp;</td>
            <td align="left">&nbsp;</td>
          </tr>
           <tr>
            <td valign="top" align="right">&nbsp;</td>
            <td colspan="2" align="left">&nbsp;</td>
            </tr>
            <tr>
            <td colspan="3" align="center" width="750px;">
             <table width="100%" border="0" cellspacing="0" cellpadding="0">
             <tr style="font-size:11px;">
    <th>City</th>
    <th>Banner</th>
    <th>Short Description</th>
    <th>&nbsp;</th>
</tr>
            <tr class="table-row" id="box_new_product">
    <td width="20%">
    <select name="City[]" id="City[]" >
          <option value="Bangalore">Bangalore</option>
          <option value="Chennai">Chennai</option>
          <option value="Delhi-NCR">Delhi-NCR</option>
          <option value="Hyderabad">Hyderabad</option>
          <option value="Kolkata">Kolkata</option>
          <option value="Mumbai">Mumbai</option>
          <option value="Pune">Pune</option>
        </select>
            </td>
    <td width="50%"><input type="file" name="CategoryBanner[]"  /></td>
    <td><textarea name="detail[]" id="detail[]" rows="3" cols="30"></textarea></td>
    <td>
        <script type="text/javascript" src="js/node_cloning.js"></script>
<span class="nowrap"><img src="images/icon_add.gif" width="13" height="18" border="0" name="add" id="new_product" alt="Add empty item" title="Add empty item" onclick="$('#box_' + this.id).cloneNode(1); " class="hand" align="top" />&nbsp;<img src="images/icon_clone.gif" width="13" height="18" border="0" name="clone" id="new_product" title="Clone this item" alt="Clone this item" onclick="$('#box_' + this.id).cloneNode(1, true);" class="hand" align="top" />&nbsp;<img src="images/icon_delete_disabled.gif" width="12" height="18" border="0" name="remove" id="new_product" alt="Remove this item" title="Remove this item" class="hand" align="top" /><img src="images/icon_delete.gif" width="12" height="18" border="0" name="remove_hidden" id="new_product" alt="Remove this item" title="Remove this item" class="hand hidden cm-delete-row" align="top" />&nbsp;</span>
</td>
</tr>
            </table>
                             </td></tr>
               <tr>
            <td valign="top" align="right" style="font-size:11px;">Set The Flag ::&nbsp;</td>
            <td colspan="2" align="left">&nbsp;<select name="Flag">
    <option value="False" >False</option>   
    <option value="True" >True</option>
    </td>
            </tr>
          <tr>
            <td valign="top" align="right">&nbsp;</td>
            <td colspan="2" align="left">&nbsp;</td>
            </tr>
                 <tr>
            <td>&nbsp;</td>
            <td colspan="2">&nbsp;</td>
          </tr>
 
            <tr>
            <td>&nbsp;</td>
            <td>
                        <input name="submit" type="submit"  value="Submit" id="submit" class="button" />  </td>
          </tr>
            </form>
            </table>
</div></div>
</body>
</html>
<?php   ob_flush();?>
 
I dont know what is the problem.
When i try to upload single file it works fine.
But when i try to upload multiple file all the file names are stored in array called $CategoryBanner
but then when i try to print array of $_FILES['CategoryBanner']['name'] then it does not give me file names.
There is no error.
I try also with $_HTTP_POST_FILES but still no success.

I am stuck here.
Please help me.