We help IT Professionals succeed at work.
Get Started

Having Trouble with an image upload script...

blink10
blink10 asked
on
278 Views
Last Modified: 2012-05-12
I am trying to let users upload a image to my server, however, i am having no luck with the current script...it doesnt seem to copy to the specified directory even when i change the permissions to writable...so i am wondering if anyone sees any errors.

Thanks.
<?php include('sessions01.php');
?>
<?php


$dbh = mysql_connect($hostnameSERVER, $usernameSERVER, $passwordSERVER) 

	or die("Unable to connect to MySQL");

mysql_select_db($dbSERVER, $dbh);

// let get the users email address
$email=$row4['Email'];
$pid=$row4['P_Id'];

//this is to upload a new image to the users account


if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000))
  {
  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 />";


      move_uploaded_file($_FILES["file"]["tmp_name"],
      "http://www.billsprice.com/images/icons/" . $_FILES["file"]["name"]);
	  echo $_FILES["file"]["name"];
      echo "Stored in: " . "http://www.billsprice.com/images/icons/" . $_FILES["file"]["name"];
      
	      
	    $error = "24";

//		header("location:http://www.billsprice.com/myaccount.php?message=$error");
	  
    }
  }
else
  {

$error = "Your file is an invalid format, you must upload only files specified below.";

header("location:uploadform.php?forget=$passe&error=$error");

  }
// let get the previous 


//this is adding the file to the database

//if it is ok then we are going to update the user information table as needed

//$image=;

//mysql_query("UPDATE Persons SET image = '$image' WHERE Email = '$email'");


?>

Open in new window

Comment
Watch Question
Most Valuable Expert 2011
Author of the Year 2014
Commented:
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE