Jump to content


Photo

Image upload help!


  • Please log in to reply
2 replies to this topic

#1 renno

renno
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 12 September 2006 - 03:18 PM

I have been searching the web for ages and found loads of tutorials on how to save a jpeg into a blob using mysql but many articles say that access time to and from the database are slow.

Does anyone know of a simple working tutorial that allows you to upload a file to a folder on web server and the save location of this file (a string) in an sql database so it can be referenced and displayed simply in another web page?

Apologies if this has problem has been posted many times before...

Any help would be much appreciated...

Cheers.

#2 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 12 September 2006 - 03:22 PM

Here try this:

  <?
// Where the file is going to be placed 
$target_path = "uploads/";

/* Add the original filename to our target path.  
Result is "uploads/filename.extension" */
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
$_FILES['uploadedfile']['tmp_name'];  
$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";
} else{
    echo "There was an error uploading the file, please try again!";
}
?>

You can hold file basename in array and insert it in db.
$file_name = basename( $_FILES['uploadedfile']['name']); // $file_name will be inputed in db

I don't need your script, I'll try to write it myself

#3 renno

renno
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 12 September 2006 - 03:26 PM

many thanks, will give it a go...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users