Re: Wow, this is weird

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Monday, August 27, 2012 07:47:18 PM Robert Palmer wrote:
> Try $_FILES['image']['name'];

I tried this, as Matt Pelmear suggested. It somewhat works, it adds 
Array[name] into the database instead of the image name.

> 
> But are you trying to load the name of the image or the image itself
> into the database? Do you want the image uploaded?

I just want the name uploaded into the db. the image upload is already working 
as I expect.

Here's the code for the upload. It uploads the file and then checks to see if 
it's a valid image with getimagesize() and if it's a valid image file, it will 
put it in the image folder, otherwise it will fail to upload anything and spit 
an error.

and at the same time, If the image checks out, I am trying to add just the 
image name into the db

$target_path = $target_path . $_FILES['image']['name'];

$target_path =SITE_ROOT .  "/images/";

$target_path = $target_path . $_FILES['image']['name']; 

if(move_uploaded_file($_FILES['image']['tmp_name'], $target_path)) {

  if (getimagesize ($target_path)){
  
    echo "its an image<br />";

David M.
> 
> On 8/27/2012 7:32 PM, David McGlone wrote:
> > On Monday, August 27, 2012 10:11:32 PM lists-php wrote:
> >> ------------ Original Message ------------
> >> 
> >>> Date: Monday, August 27, 2012 06:04:28 PM -0400
> >>> From: David McGlone <david@xxxxxxxxxxxxx>
> >>> To: php-db@xxxxxxxxxxxxx
> >>> Subject:  Wow, this is weird
> >>> 
> >>> Hi Everyone
> >>> 
> >>> I have written some code that works almost 100% like I expect, but
> >>> for the  life of me I cannot figure out why the image name is not
> >>> being inserted into  the database. I've posted the code on
> >>> pastebin, can anyone spot something  amis?
> >>> 
> >>> http://pastebin.com/mGBFrxwP
> >>> 
> >>> David M.
> >> 
> >> Start by trying basic debugging -- echo your mysql insert statement
> >> and see what the values are.
> > 
> > I echoed all the values and Image come up blank on the results page and in
> > the database. Everything else works as intended.
> > 
> > $image = $_POST['image'];
> > echo $image;
> > echo "<br />";
> > $year = $_POST['year'];
> > echo $year;
> > echo "<br />";
> > $make = $_POST['make'];
> > echo $make;
> > echo "<br />";
> > $model = $_POST['model'];
> > echo $model;
> > echo "<br />";
> > $milage = $_POST['milage'];
> > echo $milage;
> > echo "<br />";
> > $price = $_POST['price'];
> > echo $price;

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux