View previous topic :: View next topic |
Author |
Message |
os17fan -
Joined: 21 Mar 2003 Posts: 531 Location: USA
|
Posted: Fri Oct 17, 2003 10:24 pm Post subject: Upload Form error: Please help! |
|
|
I just created my own upload form script but I always get a error 200 and im sure that I coded it right , can you please tell me if it has errors in it.
I numbered the code so you can tell me what line has the error.
-------------------------------------------------------------------------------------
Code: | 1. <?php
2. if ($file){
3. print ("File name: $file_name<p>\n");
4. print ("File size: $file_size<p>\n");
5. if (copy ($file, "users/$file_name")){
6. print ("Your file is now uploaded!<p>\n")
7. }else{
8. print ("Your file was not uploaded.<p>\n");
9. }
10. unlink ($file);
11. }
12. print ("Upload a file to the server:\n");
13. print ("<form action=\"upload.php\" method=\"post\" enctype=\"multipart/form-data\">\n");
14. print ("file <input type=\"file\" name=\"file\" size=\"20\"><br>\n");
15. print ("<input type=\"submit\" value=\"Upload\"></form>\n");
16. ?>
|
_________________ This web server is the best ! |
|
Back to top |
|
|
!Keys -
Joined: 23 Nov 2002 Posts: 156 Location: Holland, Enschede
|
Posted: Sat Oct 18, 2003 6:20 pm Post subject: |
|
|
Hi ppl, im back...
First of all, learn to code decently :roll:.
Then, the code is correct, it just doenst give any output. _________________ !Keys || MwM^computerware |
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
|
Back to top |
|
|
os17fan -
Joined: 21 Mar 2003 Posts: 531 Location: USA
|
Posted: Sun Oct 19, 2003 8:10 pm Post subject: |
|
|
I guess I will rewrite my upload script , Larry Ullman PHP programmer , I learned that type of stuff from his book. I hope he didn't make a mistake. 8)
I will post my success upload script here ! _________________ This web server is the best ! |
|
Back to top |
|
|
os17fan -
Joined: 21 Mar 2003 Posts: 531 Location: USA
|
Posted: Sun Oct 19, 2003 9:38 pm Post subject: |
|
|
I finally did it , after reviewing all the errors with the php.ini and all the other lines , I finally got a perfect working script.
In a text editor , copy this code and name it FileUpload.php and browse to the file using http://your-site.com/php_path/FileUpload.php and your done. This script is very cool because it will display the file name and file size after you upload something.
I will create my File Upload manager soon so you guy's can look forward to that one. Enjoy the script! :D
Code: |
<html>
<head>
<title>Your Title Here</title>
</head>
<body>
<?php
if ($file){
print ("File name: $file_name<p>\n");
print ("File size: $file_size<p>\n");
if (copy ($file, "C:\your_path/$file_name")){
print ("Your file is now uploaded!<p>\n");
}else{
print ("Your file was not uploaded.<p>\n");
}
unlink ($file);
}
print ("Upload a file to the server:\n");
print ("<form action=\"FileUpload.php\" method=\"post\" enctype=\"multipart/form-data\">\n");
print ("file <input type=\"file\" name=\"file\" size=\"20\"><br>\n");
print ("<input type=\"submit\" value=\"Upload\"></form>\n");
?>
</html>
</body>
|
-------------------------------------------------------------------------------------
Larry Ullman Rocks _________________ This web server is the best ! |
|
Back to top |
|
|
|