Image uploading problem

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
budhankundu
Forum Newbie
Posts: 1
Joined: Sat Apr 12, 2008 12:24 am

Image uploading problem

Post by budhankundu »

Hi,
I can't upload image to my Global Server but the code works fine in local server. Please solve it. My code is written bellow...
Code :

***** PLEASE USE THE CODE OR PHP TAGS WHEN POSTING *****

Code: Select all

if(isset($_REQUEST['insert'])){
            $p_name=$_REQUEST['p_name'];
            $p_price=$_REQUEST['p_price'];
            $desc=$_REQUEST['desc'];
            $insdate=date('Y-m-d');
            $i=date('Y-m-d h-m-s');
            $sorce=$_FILES['p_image']['tmp_name'];
            $des=$_FILES['p_image']['name'];
            $im=$i.$des;
          if(file_exists("Image/".$im)){
                unlink("Image/".$im);
            }
          copy($sorce,"Image/".$im) or die ("Could not copy");
          
$sql_s="INSERT INTO product (p_name,p_desc,p_price,p_image,adddate) VALUES('".$p_name."','".$desc."','".$p_price."','".$im."','".$insdate."')";
 
                if($res_s=mysql_query($sql_s)){
                $msg="insert successfully";
                }else{
                $msg="Try again";
                }
}
bdlang
Forum Contributor
Posts: 395
Joined: Tue May 16, 2006 8:46 pm
Location: Ventura, CA US

Re: Image uploading problem

Post by bdlang »

Unless you have reason to believe at this point in time that the INSERT statement is at fault, this likely belongs in the PHP forum.

Is it the image upload that doesn't work or the database code?

You don't say what the differences are between the 'global server' vs. the local machine. What versions of PHP / MySQL are each host running? Is your development machine Windows and the web host Linux?

Use mysql_error() to trap any errors returned by the query call.
Please solve it.
There may be a language barrier, e.g. you're not a native English speaker; I realize this is your first post in the forum, but that statement is a bit rude. If you want us to "solve it", pay us. Otherwise, the forum is meant for us to point you in the right direction so you solve the problem.
Post Reply