Jump to content

[SOLVED] how to send data to database?


Darkwoods

Recommended Posts

how do i send thumb file name to my database

 

here is the thumbnail creator page

<?php
include "../admin/inc/header.php";

if(isset($_POST['submit']))

   {
     $new_height=100;
     $new_width=100;

     $allowed_types = array( 
     'image/pjpeg', 
     'image/gif', 
     'image/png', 
     'image/jpeg'); 

     if(in_array($_FILES['thefile']['type'], $allowed_types)) 

     {
       copy ($_FILES['thefile']['tmp_name'], $_FILES['thefile']['name']) or die ("Could not copy");

       echo "Name: ".$_FILES['thefile']['name']."";
       echo "Size: ".$_FILES['thefile']['size']."";
       echo "Type: ".$_FILES['thefile']['type']."";  

       $imagefile=$_FILES['thefile']['name'];

       list($width, $height) = getimagesize($_FILES['thefile']['name']);
       $image_p = imagecreatetruecolor($new_width,$new_height);
   

       if ($_FILES['thefile']['type'] == "image/gif") 
       {
           $img = @imagecreatefromgif($imagefile);

           imagecopyresampled($image_p, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
           $thename=$_FILES['thefile']['name'];
           $thenames="thumb$thename";
           $location="thumbs/$thenames";
           imagegif($image_p,$location, 100);
       }
       else
       {

         $img = @imagecreatefromjpeg($imagefile);
         imagecopyresampled($image_p, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
         $thename=$_FILES['thefile']['name'];
         $thenames="thumb$thename";
         $location="$thenames";
         imagejpeg($image_p,$location, 100);
       }
     }

     else

     {
       print "<br>Only Gifs and Jpegs are supported. Back to <A href='../admin/test.php'>Control Panel</a>";
     }
   }

include "../admin/inc/footer.php";
  
?>

 

i tried with this code but without any luck

$name=$_POST['name'];
$thefile2=$_FILES['thefile']['name'];

		//Writes the information to the database
		$result = mysql_query("INSERT INTO latest (thefile, name)
                       VALUES ('$thefile2','$name')",$connect);

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.