Jump to content

Problem with image path and a browser.(firefox)


phpRoshan

Recommended Posts

Hi

 

  I have managed to create a script which uploads the image file successfully and save image path in database.here it is,

 

function uploadImg($producId)

  {

        //THIS FUNCTION UPLOADS THE IMG FILE TO THE IMG DIRECTORY LOCATED IN

        //PRODUCTS DIRECTORY.THIS TAKES THE PRODUCT ID AS A PARAMETER AND SETS

        //IT AS THE IMAGE FILE NAME TO BE IDENTIFID UNIQLY.ex- PRODID =4

        //FILE NAME WOULD BE 4_IMGFILE.GIF

 

        //SETS THE IMG FOLDER PATH

        $cpath = $_SERVER['DOCUMENT_ROOT'];

        $path ="$cpath/computerShop/administration/Products/img";

 

 

        //GET THE UPLODED IMG FILE NAME. AND SET THE PROPER IMG FILE NAME

        $imgName = $_FILES ['txtProdImgPath']['name'];

        $imgName = $producId ."_". $imgName ;

 

 

        if($_FILES ['txtProdImgPath']['size']>0)

        {

            //COPY THE UPLODED FILE INTO THE EXAC DESTINATION

            if(copy($_FILES ['txtProdImgPath']['tmp_name'],"$path/$imgName" ))

            {

                //AFTER COPYIN IT DELET THE TEMP FILE

                if(unlink($_FILES ['txtProdImgPath']['tmp_name']))

                {

                  return $img_path = $path ."/". $imgName;

                  exit;

 

                }

 

            }

 

        }

        return $img_path = $path ."/noImg.gif";

 

  }//end of uploadImg()

 

 

But the problem begins not with this script but with the browser which i used to view the output.which is firefox.

 

    One time suddenly i used IE browser to see the out put of this script.to my sureprice i found it that page displays all the images which i cudnt see on firefox.  followings are the code which i used to output.I have only part of the code pasted because it would be too long if i did so.

 

 

function getProducts()

  {

    $dbObj = new Databas();

    $dbObj->connectDB();

    $prodQry = "SELECT * FROM PRODUCTS";

    $prodQryRst = mysql_query( $prodQry );

 

    return $prodQryRst;

 

  }//end of getProducts()

 

  function displayProducts()

  {

 

    $prodRst = $this->getProducts();

    ?>

      <center>

     

    <?

 

    while($product = mysql_fetch_array($prodRst  ,MYSQL_ASSOC))

    {

 

      echo "<div class='products'>";

      echo "<img src =\"".$product['image_path']."\" width =\"200\" height =\"200\" />";

      echo "<br />";

      echo $product['product'];

      echo "</div>";

 

    }//END OF WHILE

 

    ?>

 

    </center>

 

    <?

 

 

 

  }//end of displayProducts()

 

 

              Could anybody explain me why this is happening? or is there any other way to display images on a page? im still a newbie for php.

 

Thanks in advance.

Roshan

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.