Upload Form error: Please help!

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
os17fan
-


Joined: 21 Mar 2003
Posts: 531
Location: USA

PostPosted: Fri Oct 17, 2003 10:24 pm    Post subject: Upload Form error: Please help! Reply with quote

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 View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
!Keys
-


Joined: 23 Nov 2002
Posts: 156
Location: Holland, Enschede

PostPosted: Sat Oct 18, 2003 6:20 pm    Post subject: Reply with quote

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 View user's profile Send private message MSN Messenger
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Sun Oct 19, 2003 11:33 am    Post subject: Re: Upload Form error: Please help! Reply with quote

os17fan,

The code contains some errors. It is better to build your script upon the sample upload script we gave in http://www.aprelium.com/forum/viewtopic.php?t=2144 .
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
os17fan
-


Joined: 21 Mar 2003
Posts: 531
Location: USA

PostPosted: Sun Oct 19, 2003 8:10 pm    Post subject: Reply with quote

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 View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
os17fan
-


Joined: 21 Mar 2003
Posts: 531
Location: USA

PostPosted: Sun Oct 19, 2003 9:38 pm    Post subject: Reply with quote

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 View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group