Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Problems with updating an uploaded picture.

New Here ,
Mar 02, 2010 Mar 02, 2010

I have a problem with changing a picture for a record in a database.

Basically a picture is uploaded to an upload folder and the filename stored in the database.

Inserting/viewing the picture is fine but I have now included a separate update program and the ($_FILES["PictureLocation"]) is never set, even though it has virtually the same code as the insert program.

All other fields are updated fine.

I have included code for both the check for $_FILES["PictureLocation"] and the setting up of  $_FILES["PictureLocation"] for both the INSERT and UPDATE functions.

Why is $_FILES["PictureLocation"] not set in the update program??

INSERT CODE........

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1"))
{

     //Сheck that we have a file
     if((!empty($_FILES["PictureLocation"])) && ($_FILES['PictureLocation']['error'] == 0))
    {

          // copy file to upload folder + add filename to database.

       <tr>
              <td align="right" nowrap="nowrap"><strong>PictureLocation:</strong></td>
              <td bgcolor="#CCFFCC"><input type="file" name="PictureLocation" value="" size="20" /></td>
              <td> </td>
              <td bgcolor="#FFFFFF"> </td>
            </tr>

UPDATE CODE.......

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form4"))

{

         //Сheck that we have a file
        if((!empty($_FILES["PictureLocation"])) && ($_FILES['PictureLocation']['error'] == 0))
         {    

       // copy file to upload folder + add filename to database.

  <tr valign="baseline">
              <td nowrap="nowrap" align="right"><strong>Picture</strong></td>
              <td bgcolor="#CCFFCC"><input type="file" name="PictureLocation" value="" size="20" /></td>
              <td bgcolor="#CCFFFF"> </td>
            </tr>

TOPICS
Server side applications
238
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 02, 2010 Mar 02, 2010
LATEST

I have now resolve this    

The enctype="multipart/form-data"was missing

  <form action="<?php echo $editFormAction; ?>" enctype="multipart/form-data" method="post" name="form4" id="form4">

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines