I have a created a page to upload images. Can someone please help me. When when I click on browse I would like the picture to go on the server and not change the image name. just to upload the image as it is. please help

<?php

include('../includes/cms.config.php');

require_once('login.php');

## Get MySql DB Settings
session_start();
$dbconn = mysql_connect($server,$user,$password) or die('Cannot connect');
mysql_select_db($db) or die('Cannot select db');

if ((isset($_GET['cat']) or isset($_POST['cat']))){
if (($_GET['cat']=="Add Product")or($_POST['cat']=="Add Product")){
if (isset($_POST['product'])){

$pname = $_POST['product'];
$pcode = $_POST['productcode'];
//$pimage = $_POST['image'];
$pcat = $_POST['category'];
$pdesc = $_POST['fulldesc'];
$prank = $_POST['rank'];
$pprice = $_POST['price'];
$today = date("Y/m/d");

        if($_FILES['pictureFile']['tmp_name'] == "none"){
            echo "<b>File did not successfully upload. Check the
            file size. File must be less than 500K.<br>";
            include("product.php");
            exit();
        }
/*
        //check to see if the file is an image
         if(!ereg("image",$_FILES['pictureFile']['type'])){
            echo "<b>File is not a picture. Please try another
            file.</b><br>";
            include("product.php");
            exit();
        }
        else */
        {   
                        [B]//$destination = './images'."/".$_FILES['pictureFile']['name'];
                       $destination = "./images/".$_FILES['pictureFile']['name'];
          $temp_file = $_FILES['pictureFile']['tmp_name'];
                     @move_uploaded_file($temp_file,$destination);[/B]

            //get the values
            $pimage = $_FILES['pictureFile']['name'];

            $query = "INSERT INTO tblproduct (`ProductCode`,`Date`,`ProductName`, `Image`, `Category`, `ProductDescription`, `Rank`, `Price`) VALUES ('$pcode','$today','$pname','$pimage','$pcat','$pdesc','$prank','$pprice')";

What is the error ?
$pimage is null ! If you want the image name to be inserted to the table, you should insert $_FILES.

All i need is help to to just move the pic to the webserver. For some reason the image doesnt want to be moved:icon_cry:

Umm.. Do you have enctype in the form ? Are you sure image is getting posted ? Check for permissions of the destination directory. Remove @ before move_uploaded_file, as @ supress any error message.

Edit: Btw, many of your if and else { are not closed. Have you disabled error reporting ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.