Jump to content

[SOLVED] Trying to upload file


djsl

Recommended Posts

Hi

 

I am trying to set up where members in my site upload files and then all the members to be able to have access to them.

I have gotten the script to upload the file to the proper directory but when I update the the table it does not update the location and name but the actual variable "SELECT * FROM members WHERE username='$username'". 

 

What am I doing wrong?

Also if I want to allow other types of files like a txt or pdf what would be the type for the script to filter where image is "image/gif"

thanks

 

<?php

require('includes/handler.php'); 
$query="SELECT * FROM members WHERE username='$username'";

$target_path = "upload/$username/";

$appraisalfilelocation=  '. $target_path . $_FILES["file"]["name"]';

if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/doc"))
&& ($_FILES["file"]["size"] < 90000))
  {
  if ($_FILES["file"]["error"] > 0)
    {
   echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
   }
  else
   {
  echo "Upload: " . $_FILES["file"]["name"] . "<br />";
   echo "Type: " . $_FILES["file"]["type"] . "<br />";
   echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
   echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";

    if (file_exists("upload/" . $_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["file"]["tmp_name"],
      $target_path . $_FILES["file"]["name"]);
      echo "Stored in: " . $target_path . $_FILES["file"]["name"];

      }
    }
}
else
  {
echo "Invalid file";
   }


mysql_query("UPDATE members SET appraisal_file_location = $appraisalfilelocation
WHERE username = '$username'");


?> 


Link to comment
https://forums.phpfreaks.com/topic/170713-solved-trying-to-upload-file/
Share on other sites

ok I changed the line and added the error reporting

thanks for your help

 

here is what I got for the error

 

Notice: Undefined index: custom in  includes/csecure.php on line 70

 

csecure.php is the page that tells users that they are banned and line 70 is:

$custom = kry_db_input($_POST['custom']);

 

here is the code from that page


$_ip = getenv('REMOTE_ADDR');
if (defined('SITE_NAME'))
{
	$custom = kry_db_input($_POST['custom']);
	$result = kry_db_query("select * from banned where banned_ip = '" . $_ip . "' and type = 'M' ");
	if ($myrow = kry_db_fetch_array($result))
	{
			die($_error_message);
	}
	$member_id = $_SESSION['member_id'];
	$accQuery = kry_db_query("select members_email_address from members where members_id = '" . (int)$member_id . "' ");
	$accRes = kry_db_fetch_array($accQuery);
	$email = $accRes['members_email_address'];
	$result = kry_db_query("select * from banned where banned_email = '" . $email . "'");
	if ($myrow = kry_db_fetch_array($result))
	{
			die($_error_message);
	}
}
else
{
	die($_error_message);
}

 

 

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.