Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2011
    Posts
    52
    Thanks
    24
    Thanked 0 Times in 0 Posts

    Question Image upload script won't work

    I made a script that uploads images to a database but the problem is i see blob and the size of image in database but can't see the file in temp folder or directory i am moving it to uploads fine but can't find image code is below please help

    PHP Code:
    if(isset($_POST['subbutton'])){

    $name $_POST['namet'];
    $email $_POST['emailt'];
    $about $_POST['about'];
    $location $_POST['locationt'];
    $website $_POST['websitet'];
    $date date('F d, Y');
    $comment $_POST['commentt'];

            
    $uploadDir 'testimonial'//Image Upload Folder

            
    $fileName addslashes($_FILES['pict']['name']);
            
    $tmpName  $_FILES['pict']['tmp_name'];
            
    $fileSize $_FILES['pict']['size'];
            
    $fileType $_FILES['pict']['type'];
            
    $filePath addslashes($uploadDir $fileName);
            
    $result move_uploaded_file($tmpName$filePath);
    if (!
    $result) {
    echo 
    "Error uploading file.";
    exit;
    }


    if(
    $name!=""){
        
    $query="INSERT INTO testimonial(id, name, email, about, location, website, picture, date, comment)
                  VALUES ('', '$name', '$email', '$about', '$location', '$website', '$filePath', NOW(), '$comment')"
    ;
                  
    mysql_query($query)  or die(mysql_error());
                  echo 
    "<br/><b style='color:green'>Your testimonial has been received</b>";
    }else{
      echo 
    "<br/><b style='color:red;'>there was an error.</b>";
    }
      
    $to "some@gmail.com";
    $subject "Testimonial approval request";
    $name $_POST['namet'];
    $email $_POST['emailt'];
    $comment $_POST['commentt'];
    $message "
    Name: $name $email<br/>
    Email: $email_field<br/>
    Message: $comment"
    ;
    $headers  'MIME-Version: 1.0' "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";
    // Additional headers
    /*$headers .= 'To: <[email address goes here]>' . "\r\n";
    $headers .= '[From] <[email address goes here]>' . "\r\n";*/
    // Mail it
    mail($to$subject$message$headers);    
      

    my form:

    Code:
    <form action="" method="post" enctype="multipart/form-data">
     <table width="450" border="0">
    
      <tr>
    
        <td width="107PX" align="right" valign="top">Your Name<font color="#FF0000"> *</font>      :</td>
    
        <td>&nbsp;</td>
    
        <td width="303PX" class="TEXTBG">
    
        <input  type="text" name="namet" value="" class="tesxtbox"/>
    
        </td>
    
      </tr>
    
      
    
      <tr>
    
        <td width="107PX" align="right" valign="top">E mail Address  <font color="#FF0000"> *</font>      :</td>
    
        <td>&nbsp;</td>
    
        <td width="303PX" class="TEXTBG">
    
        <input  type="text" name="emailt" value="" class="tesxtbox"/>
    
        </td>
    
      </tr>
    
      
    
      <tr>
    
        <td width="107PX" align="right" valign="top">About You      :</td>
    
        <td>&nbsp;</td>
    
        <td width="303PX" class="TEXTBG">
    
        <input  type="text" name="about" value="" class="tesxtbox"/>
    
        </td>
    
      </tr>
    
      <tr>
    
        <td width="107PX" align="right" valign="top">Your Location         :</td>
    
        <td>&nbsp;</td>
    
        <td width="303PX" class="TEXTBG">
    
        <input  type="text" name="locationt" value="" class="tesxtbox"/>
    
        </td>
    
      </tr>
    
      
    
      <tr>
    
        <td width="107PX" align="right" valign="top">Your Website         :</td>
    
        <td>&nbsp;</td>
    
        <td width="303PX" class="TEXTBG">
    
        <input  type="text" name="websitet" value="" class="tesxtbox"/>
    
        </td>
    
      </tr>
    
      
    
      <tr>
    
        <td width="107PX" align="right" valign="top">Your Picture       :</td>
    
        <td>&nbsp;</td>
    
        <td width="303PX" ><input  name="pict" type="file"/></td>
    
      </tr>
    
      <tr>
    
        <td width="107PX" align="right" valign="top">Your Security        :
    
        <!--<img src="<?php /*bloginfo('template_url');*/ ?>/captcha.php/"/>-->
    
        </td>
    
        <td>&nbsp;</td>
    
        <td width="303PX" class="TEXTBG">
    
        <input  type="text" name="securityt" value="" class="tesxtbox"/>
    
        </td>
    
      </tr>
    
      
    
      <tr>
    
        <td width="107PX" align="right" valign="top">Your Comments        :</td>
    
        <td>&nbsp;</td>
    
        <td width="303PX" class="TEXTBG2">
    
       <textarea rows="" cols="" name ="commentt" id="box01" class="textareabox01"></textarea>
    
        </td>
    
      </tr>
    
        <tr>
    
        <td width="107PX" align="right" valign="top">&nbsp;</td>
    
        <td>&nbsp;</td>
    
        <td width="303PX" >
         
    	 <input type="submit" name="subbutton" value="" id="subbutton" onClick="return validate_login_forgot(this.form)"/>
      <!--<a href="#"><img src="<?php /*bloginfo('template_url');*/ ?>/images/btn_03.jpg" width="89" height="37" align="right" /></a>-->
    
        </td>
    
      </tr>
    
     
    </table>
    </form>
    Last edited by gazaian1; 09-18-2012 at 12:48 AM.

  • #2
    Regular Coder
    Join Date
    Sep 2002
    Posts
    456
    Thanks
    0
    Thanked 20 Times in 20 Posts
    Yours is probably just the dir path:
    $uploadDir = 'testimonial'; //Image Upload Folder

    $fileName = addslashes($_FILES['pict']['name']);
    $filePath = addslashes($uploadDir . $fileName);

    states your file path would be:
    testimonialimagename.ext

    $uploadDir = 'testimonial/'; //adding the slash makes the dir.

    $fileName = $_FILES['pict']['name'];
    $filePath = addslashes($uploadDir . $fileName);

    should fix it...my script say they have moved and show in directory but posts empty file. So I hope this works for you.
    NO Limits!! DHCreationStation.com
    ------------------------------------------------------------
    Broken items wanted for tinkerin'! PostItNow@BrokenEquipment.com
    Global Complaint Dept.


  •  

    Tags for this Thread

    Posting Permissions

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