Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to upload files to MySQL databse and view it on the webpage

Status
Not open for further replies.

newlearner2005

Programmer
May 9, 2005
32
US
Hello everybody,

I have hard hard time to upload a file to the webpage, viewing and store it in MySQL database.
I am using apache, PHP and MySQL
I found the code on-line and tried to practice but it did not work. They said I need two files
Here is the first file "upload.html"

<html>
<head>
<title>file upload form</title>
</head>

<body>
<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000"/>
Choose a file to Upload: <input name="uploadedfile" type="file"/><br/>
<input type="submit" value ="Upload File"/>
</form>

</body>
</html>

Here is the second file "uploader.php"

<?php

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

// Add the original file name to our target path. Result is
// "uploads/filename.extension"
$target_path = $target_path.basename($_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmpname'], $target_path))
{
echo "The file ".basename($_FILES['uploadedfile']['name']). " has been uploaded";
}
else
{
//echo "There was an error uploading the file, please try again!";
echo "There was an error uploading the file. What the hell ! I am so disappointed!";
}

?>
Why it did not work ?
"basename" is a key word or I have to replace it ?
$target_path = "uploads/"; "uploads/" is a keyword too?

Could anybody help me ? I really appreciate.
Thank you so very much.
new learner
 
I am sorry for not describing it clearly.
OK, let make it simple.
How to
1- Upload a file to server ? (by using PHP/HTML language programming)
2- If it is OK, how to display that file on the webpage (click on the the link of that file. Example: if i click on "file1.txt" it will give me two choice "open or save" )
3- Store that file to MySQL server. (window 2000 as a server)

Thank you very much. I really appreciate.
new learner
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top