Jump to content

update file uploaded to table


steviemac

Recommended Posts

I want to be able to update a table in a database that also sends a file to a folder on the server.

It will send the file to the server  but will not update the table.

This is my code

<?php
include "dbmembers.php";

if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/jpg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 40000))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
  
    

    if (file_exists("members_images/" . $_FILES["file"]["name"]))
      {
  echo "<B>This name ";
      echo $_FILES["file"]["name"] . " that you have named your file already exists on the server. Please rename it and  upload it again.</B>";
      }
    else
      { 
  (mysql_query("UPDATE allmembers set photo = '".mysql_real_escape_string($_POST['file']['name'])."' where id = '".mysql_real_escape_string($_POST['id'])."'") or die(mysql_error())) ;
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "members_images/" . $_FILES["file"]["name"]);
      echo "Your file "  . $_FILES["file"]["name"] . " has been successfully uploaded to the server.";
  
      }
    }
  
else
  {
  echo "Invalid file format.  You file is not a .gif or .jpg extension or is to large in size.";
  }
  
?>

 

Thank you for your help

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.