www.webdeveloper.com
Results 1 to 3 of 3

Thread: Image Issue

  1. #1
    Join Date
    Jan 2010
    Posts
    127

    Image Issue

    Ok I have had a look at the Image upload thread, and have downloaded the files to have a look.

    However I need to sort out a pre-exisiting file upload for someone and how it looks to me is that most of whats in that thread is in this file.

    The following is the PHP section of the file.

    PHP Code:
    <script src="js/select-subject.js" type="text/javascript"></script>
    <?php
    require_once "FCKeditor/fckeditor.php";
    if(isset(
    $_REQUEST['btnSubmit'])){
            
            
    $bool=false;
            
    $class->begin();

            
    $prID=$class->getMaximum("prID","ver_pro")+1;
            
            
    $cID=$_REQUEST['subjects'];
            
    $pID=$_REQUEST['links'];
            
    $mID=1;
            
    $name=$class->sql_quote($_REQUEST['name']);
            
    $avail=$class->sql_quote($_REQUEST['avail']);
            
    $prCode=$class->sql_quote($_REQUEST['prCode']);
            
    $price=$class->sql_quote($_REQUEST['price']);
            if(
    $_FILES['ImageFile']['name']!=''){
            
    $image_path=$_FILES['ImageFile']['name'];
        }else{
            
    $image_path="default1.gif";
        }
            
    $description=$class->sql_quote($_REQUEST['description']);
            
    $stitle=$class->sql_quote($_REQUEST['stitle']);
            
    $sdescription=$class->sql_quote($_REQUEST['sdescription']);
            
    $skeywords=$class->sql_quote($_REQUEST['skeywords']);
            
            
    $active=1;
            
            
            
    $otherpro $_POST['otherproduct'];
            
            
    $temp_gallery ="../upload/tmp/";
            
    $target_dir ="../upload/";
            
            
    $query="INSERT INTO ver_pro(prID,cID,pID,mID,name,avail,prCode,price,image_path,description,active,stitle,sdescription,skeywords)     
                                VALUES('"
    .$prID."','".$cID."','".$pID."','".$mID."','".$name."','".$avail."','".$prCode."','".$price."','".$image_path."','".$description."','".$active."','".$stitle."','".$sdescription."','".$skeywords."')";
                
    /*echo $query;
                die();*/
                
    if($class->executeQuery($query)==false$bool=true;
        
                if(
    $bool==true){
                    
    $class->rollback();
                    
    header("Location: index.php?cmd=11&error=0");
                    exit;
                }else{
                    
    $class->commit();
                    
                    if(
    $_FILES['ImageFile']['name']!=''){
                    
    $file1=$temp_gallery.$ID.$_FILES[ImageFile][name];        
                    
    move_uploaded_file ($_FILES[ImageFile][tmp_name],$file1);
                    include_once(
    "resizeimage.inc.php");
                    
                    
    $rimg=new RESIZEIMAGE($temp_gallery.basename($file1));
                    echo 
    $rimg->error();
                    
    $rimg->resize(300,240,$target_dir."1_".basename($file1));
                    
    $filename $target_dir."2_".basename($file1);
                    
    copy($file1$filename);            
                
                            
    //$rimg->resize($target_dir."/3_".basename($file));  
                            
    @unlink($temp_gallery.basename($file1)); 
                            
    $rimg->close();
            
            }
                    
                    
    $sSQL "INSERT INTO ver_otherpro (prCode, prOther) values "
             
    $bAppened FALSE

                    foreach(
    $otherpro as $other
                           { 
                            if (
    $bAppened
                             
    $sSQL .= ','
                              else 
                            
    $bAppened TRUE;
                              
    $sSQL .= "('".$prCode."','".$other."')"
                           }
                           
                if(
    $class->executeQuery($sSQL)==false$bool=true;
                
                if(
    $bool==true){
                    
    $class->rollback();
                    
                    
                }else{
                    
    $class->commit();
                    
                            }
                    
                    
                
    header("Location: index.php?cmd=11&err=1");
                    exit;
                }
    //end of if
        
    }    
        
        
    ?>
    The file works on self, 'index.php?cmd=10' is the page which loads the form. However it works as in the fact the file path gets inserted, but then no image gets on the server, and I've double checked that it is allowed to upload... Now I never was any good at uploading pictures at uni though php, but I got there in the end, however... we had to save it into the database and I need this to go into a folder on a server.

    Basically I'm not sure how to go about getting the code in the above file working in the same way the files in the .zip from the image thread work.

    Any help I'd really appriciate!

    Aravona
    L.U.N.E for anyone and everyone who has an interest in literature

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,157
    In the form that uploads the file, did you set the <form> tag to have the attribute enctype="multipart/form-data"?
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Jan 2010
    Posts
    127
    Yes the form has that. Its just too long for this forums to accept in a post, but yet it is set up correctly, the problem does seem to be with the code.

    Everything inserts to the sql, the picture just doesn't make it to the server.
    L.U.N.E for anyone and everyone who has an interest in literature

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles