can anyone tell me how can I design a simple form through PHP that can upload pdf/doc file to a server using database along with the data submitted in the form?
What's the problem?
upload.php
File will be in "uploads" directory.Code:<?php
if(!$_POST['go'])
{
echo '<form action=upload.php method=post enctype=multipart/form-data>
<input type=hidden name=go value=go>
<input type=file name=uploadfile>
<input type=submit value=Upload></form>';
}
else
{
copy($_FILES['uploadfile']['tmp_name'],"uploads/".basename($_FILES['uploadfile']['name']));
echo 'Uploaded!';
}
?>
But it wasn't saving to file that was asked for...
but these two tutorials help you out good:
Tutorial: Storing Images in MySQL with PHP
Tutorial: Storing Images in MySQL with PHP / Part II / Display your images
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall
copy($_FILES['uploadfile']['tmp_name'],"uploads/".basename($_FILES['uploadfile']['name']));
well m confused in this line. how the two variables uploadfile and tmp_name works?
uploadname is the name of the input tag in your html, tmp_name contains a randomized name of the file while temporary stored on the server to be handled by you.
you can try print_r($_FILES) and see how the array looks like and what info you can receive from the file upload process.
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks