SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2010
    Location
    IN
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using Photo Upload script in my form....please help.

    Hi Forum,

    I am using photo upload option in my form........but it seems not to be working.

    Here's some info.......please help me as I've tried everything.....but no success.

    PHP Code:
    if($_POST['work']=="addfback")
    {
        
    // Create an object.
        //print_r($_POST);exit;
        
        
    $userfback = new userfback;
        
        
    $_POST['fb_date'] = date("Y-m-d");
        
        
    $set = array(
        
    "fb_name"=>$_POST['fdname'],
        
    "fb_email"=>$_POST['email'],
        
    "fb_contact"=>$_POST['fdcontact'],
        
    "fb_state"=>$_POST['fddrpval'],
        
    "fb_city"=>$_POST['fbcity'],
        
    "fb_photo"=>$_POST['file'],
        
    //"url"=>$_POST['url'],
        
    "fb_comment"=>$_POST['fdtext']
        );
        
        
    $fbimg $userfback->upload_file_art($_FILES['file'],"img/uimg/");
        
    //$logo1 = $banner->upload_file_art1($_FILES['logo1'],"../../banner/banner/");
        
        
    $result $userfback->add($_POST,$fbimg); 
        
        if(
    $result){
            
            
    $_SESSION["msg"] = "Thank You! for the precious feedback.";
            
            
    $url =  "../fbuser.php";

            
    header("Location: $url");
            
            die;

    /*        print("<script language='javascript'>location.href='".$url."'</script>");
            die;
    */    
    }
        else {
            
    $userfback->setsession($set);
            
    $_SESSION["msg"] = "Error! unable to add your feedback, please try again.";
            
    //header("Location: ../add_banner.php");
            
    print("<script language='javascript'>location.href='../fbuser.php'</script>");
            die;
        }
        

    Here I am adding it to my database
    PHP Code:
    class userfback extends functions
    {
        function 
    add($post,$fbimg)     //Add the news letter details to the database.
        
    {
            
    $sql_add "insert into feedback(`fb_photo`,`fb_name`,`fb_date`,`fb_email`,`fb_contact`,`fb_state`,`fb_city`,`fb_comment`) values('$fbimg','".$post['fdname']."','".$post['fb_date']."','".$post['email']."','".$post['fdcontact']."','".$post['fddrpval']."','".$post['fbcity']."','".$post['fdtext']."')";
            
    $result_add  mysql_query($sql_add);
            return 
    true;
        }

    Its not showing any error but in my table its not adding any value.

    Here's the table structure for that field.

    fb_photo
    varchar(225)
    utf8_general_ci
    No
    none

    Here's the function uploading image.
    PHP Code:
    function upload_file_art($file$path)
        {    
            
    $filename rand(1000,9999)."_".$file["name"];
            
    $tempName $file["tmp_name"];
            
    $UPLOAD_FILE =  $path."/".$filename;    
            
    $target $path."thumb/";
            
    $new_w 41;
            
    $new_h 46
            
    ini_set('memory_limit''50M');
            if(
    $tempName){
                
    //system("chmod 7777 $UPLOAD_FILE");
                
    if(move_uploaded_file($tempName$UPLOAD_FILE))
                {
                    
    $this->createthumb($filename,$path,$target,$new_w,$new_h);
                    return  
    $filename;
                }
                else
                    return 
    false;
            }
            else{
                return 
    false;
            }
        } 
    I've tried everything.............and I need help.......please check this for me.

    Any of your suggestion would be highly appreciated.

    Thanks a ton!

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    151 Post(s)
    Tagged
    3 Thread(s)
    What enctype do you have on your form? If there isnt one or its the wrong one then no FILES array is generated and no errors are alerted.

    it should be multipart/form-data
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    SitePoint Enthusiast
    Join Date
    Jan 2010
    Location
    IN
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, thanks spike, now I am having this error:

    Warning: move_uploaded_file(img/uimg/1887_Jackob.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/content/83/4759683/html/DID_index/classes/functions.class.php on line 140

  4. #4
    SitePoint Enthusiast
    Join Date
    Jan 2010
    Location
    IN
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi can anyone tell me wt's the meaning of this error.

  5. #5
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is rather simple as the warning message itself says it does not find the image
    img/uimg/1887_Jackob.jpg
    . Check folders have been created as img/uimg and 1887-Jackob.jpg file has been uploaded to the directory.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •