0

Hello basically i got a signup page and i want the user to be able to browse and upload a image and when the user clicks signup all his details and his picture will be saved to mysql database table, and when the user signs in the image appears is this possible??

4
Contributors
3
Replies
5
Views
9 Years
Discussion Span
Last Post by ditty
0

the best way is not to store it in the database itself. instead, have php uplod the image to the server, and then store the path to the image in the database

0

Hi,
I think you can use this following code for uploading an image.

<?php
include("connect.php");
// Where the file is going to be placed 
if(isset($_REQUEST['upload']))
{

$target_path = "imag/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
    " has been uploaded";
	
	
} else{
    echo "There was an error uploading the file, please try again!";
}

$f=basename($_FILES['uploadedfile']['name']);
$sql="insert into photos (path) values('$f')";
$rs=mysql_query($sql);
echo "saved";
}
?>
<form enctype="multipart/form-data" action="uploader.php" method="POST" name="form1" ">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input name="upload" type="submit" id="upload" onclick="return val();" value="Upload File" />
</form>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.