View Single Post
Old 09-30-2008, 07:58 AM   #10 (permalink)
sarmenhb
The Addict
 
sarmenhb's Avatar
 
Join Date: Jan 2008
Location: los angeles
Posts: 309
Thanks: 44
sarmenhb is on a distinguished road
Default

thats an easy one
here is the code
lets suppose your upload directory is /upload/
and your database structure is
Code:
filepath - varchar(100)
plus additional columbs if needed
the code would look something like this

Code:
<?php

if(isset($_POST['submit'])) {

$target_path = "uploads/";

$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";

//query
$query=mysql_query("insert into tbl_yourtable values(null, '$target_path'");
} else{
    echo "There was an error uploading the file, please try again!";
}










}

?>

<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
Choose a file to upload: <input name="uploadfile" type="file" /><br />
<input type="submit" value="upload" />
</form>
__________________
no signature set
sarmenhb is offline  
Reply With Quote
The Following User Says Thank You to sarmenhb For This Useful Post:
bullit (09-30-2008)