Web Analytics Made Easy -
StatCounter image not being stored on server - CodingForum


No announcement yet.

image not being stored on server

  • Filter
  • Time
  • Show
Clear All
new posts

  • image not being stored on server

    I am having some difficulty saving images to the server....

    The code produces a successful form for capturing the information...

    On the save part of the php which is where things are going wrong then the image does not save and the name of the image is also incorrect.....

    $key3 = each($input['imagename']);


    move_uploaded_file($input['imagename']['tmp_name'][$key3[0]], $this -> uploadPath.$input['imagename']['name'][$key3[0]]);

    $this -> db -> query('
    INSERT INTO brewery_location_information
    "'.$this -> imageStore.$input['imagename'][$key3[0]].'"

    The file is not uploaded to the server ... even though I have already defined where it should go....

    var $imageStore = 'http://www.cara-online.com/bqb/images/BreweryLocation/';
    var $uploadPath = '/home/web3653/website/bqb/images/BreweryLocation/';

    the data written to the Brewery_Location_Information_Value field is:
    http://www.cara-online.com/bqb/image...Location/C:\My Documents\My Pictures\0285D.gif

    as opposed to:

    I hope you can help me

  • #2

    I'm not sure exactly what your $input array contains, however, in my experience you need to be referencing a $_FILE array.

    Check out this link to see how it's supposed to be done.

    It would also be nice to see what your form code looks like. The above link uses an <input type=file....> method of uploading the file. If you're using a drag-and-drop applet, you may want to let us know a little more about that.

    Hope that helps,


    • #3
      form code

      Thanks Sadiq

      From Val

      The relevant section of form code looks like this....

      $rows = 10 - $j;
      for ($j = 1; $j <= $rows; $j ++)
      $this -> locs2 .= '<tr><td>Brewery Locations</td><td><input type="Text" value="" name="brew_addition[]"></td></tr>';

      $this -> db5 = new DB_Sql;
      $this -> db5 -> Database = $s -> getValues('auth', 'DB_name');

      $this -> db5 -> query('
      brewery_location_information_type SIT,
      media_type F
      SIT.Media_type_ID = F.Media_type_ID');

      while($this -> db5 -> next_record())
      $blit = $this -> db5 -> f('Brewery_Location_Information_Type');
      $blitid = $this -> db5 -> f('Brewery_Location_Information_Type_id');
      $format = $this -> db5 -> f('Format');
      $media = $this -> db5 -> f('Media_type_ID');

      $this -> locs2 .= '<tr><td valign="top" class="tdadminb">'.$blit.'('.$format.')</td><td>';

      if ($media==1 || $media==2 || $media==3 || $media==4 || $media==5)
      $this -> locs2 .= '<input type="file" name="imagename['.$blitid.']" class="text">';
      $this -> locs2 .= '<textarea style="width:200px;height:45px;" type="Text" name="fk['.$blitid.']" class="text"></textarea>';



      • #4
        hey v, stick [ php ] and [ /php] around your code from now on...makes it much more legible!!!

        (remove the spaces between the brackets....)


        • #5
          Ok there's two things that I would like to clarify:

          1. Is the file not being uploaded to the server at all? like it's no where to be found? even using the value in Brewery_Location_Information_Value field?

          2. The value being stored in Brewery_Location_Information_Value is wrong also.

          I'm seeing that the value of imageStore.$input['imagename'][$key3[0]] is C:\My Documents\My Pictures\0285D.gif

          Basically you're getting the whole path of that file from the user's computer that uploaded the file. I'm assuming you JUST want the file name. I'm no php guru, so I can't say off hand how to strip off the path, but that's what's necessary.

          In doing so, you may find that you'll fix the problem of actually uploading the file as well (move_uploaded_file....).

          Let us know how it goes,


          • #6

            1. Yep - no image on the server at all
            2. Yep - that is my problem - stripping the name - I have tried many things to try to do this - all unsuccessfully....

            Also - I have now noticed that the blitid was wrong as in the end of the assignment said -id and not -Id as it should have been - this causes another problem ... in that then the file type is stored in the field and the name of the file disappears - so my coding is getting a bit worse now I think... rather than better...

            Any help much appreciated


            • #7
              I don't know too much about file uploading to be quite honest with you.

              However if I were you, my next step would be to print off the values of 'tmp_name', 'name, etc.. and see what's being stored in those fields.

              I don't know if it's because you're not using the $_FILES array or not, but that seems like a standard way of doing this sort of thing.

              If you go that route, you may be able to eliminate the imagename array and merely do a foreach loop through the $_FILES array and extract your files that way, following the methods described in the link I posted in my first response.

              Other than that, I really don't know what to say. Hopefully someone else can be of more assistance.

              Good Luck!