newlearner2005
Programmer
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 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