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?
How to upload a file using a PHP script??
Started by bishisht, Sep 01 2010 05:36 AM
4 replies to this topic
#1
Posted 01 September 2010 - 05:36 AM
|
|
|
#2
Posted 01 September 2010 - 06:58 AM
What's the problem?
upload.php
File will be in "uploads" directory.
upload.php
<?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!';
}
?>
File will be in "uploads" directory.
#3
Posted 01 September 2010 - 01:42 PM
But it wasn't saving to file that was asked for...
but these two tutorials help you out good:
http://forum.codecal...-mysql-php.html
http://forum.codecal...our-images.html
but these two tutorials help you out good:
http://forum.codecal...-mysql-php.html
http://forum.codecal...our-images.html
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall
I study Information Systems at Karlstad University when I'm not on CodeCall
#4
Posted 02 September 2010 - 07:17 AM
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?
well m confused in this line. how the two variables uploadfile and tmp_name works?
#5
Posted 02 September 2010 - 12:26 PM
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.
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
I study Information Systems at Karlstad University when I'm not on CodeCall


Sign In
Create Account


Back to top









