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
https://forums.phpfreaks.com/topic/129880-solved-how-to-send-data-to-database/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.