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
https://forums.phpfreaks.com/topic/89641-update-file-uploaded-to-table/
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.