Okay, this works just dandy...except that you can overwrite files...how do I check to see if the file already exists, give a error if it does, and then repost the form?
Ugh...I tried looking at the upload section of the PHP manual last night and it made my head hurt. For the most part the manual seems to be very well laid out, just not that part I guess. That seemed like such a simple thing to be looking for. Thanks Chris. I had set up a regular expression to try to keep people from overwriting stuff...but that isn't exactly 100%. Anyway, below is my finished script for others to use if they like. I did still have one minor flaw happening...the message at the bottom of the script was supposed to be a error message, but it kept on showing up as soon as the page was loaded. I assume that somehow it is running a empty variable through my conditional...or something. Well, screw it, it works...my first PHP script. Yay. Happy me! ;D
<HTML>
<HEAD>
<TITLE>Submit.php</TITLE>
</HEAD>
<BODY>
<?php
print ("Upload your file to the server!:\n");
print ("<FORM ACTION=\"submit.php\" METHOD=POST ENCTYPE=\"multipart/form-data\">\n");
print ("File <INPUT TYPE=FILE NAME=\"File\" SIZE=20><BR>\n");
print ("<INPUT TYPE=SUBMIT NAME=\"SUBMIT\" VALUE=\"Submit!\"></FORM>\n");
$Pattern = "\.zip$";
if (eregi($Pattern, $File_name)) {
if (file_exists("uploads/$File_name")) {
// Does Exist
print ("That file name is already in use, please try another one.");
}
else {
// Does not exist
if ($File) {
print ("File Name: $File_name<P>\n");
print ("File Size: $File_size<P>\n");
if (copy ($File, "uploads/$File_name")) {
print ("Your file was successfully uploaded!<P>\n");
} else {
print ("Your file was not uploaded\n");
}
unlink ($File);
}
}
}
else {
print ("Zip files only please. If you hit submit and this message doesn't go away then your upload failed.<BR>\n");
}
?>
</BODY>
</HTML>