View Single Post
  #1 (permalink)  
Old 12-04-03, 03:27 PM
TheMetsAreBad TheMetsAreBad is offline
Newbie Coder
 
Join Date: Dec 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Help with my upload script

I'm making an upload script and I've completed pretty much everything that I want to do, except for one little thing that I can't figure out how to do. I want to have it so that it won't let people upload files with spaces in them. Can anyone tell me how I would go about doing this?

This is the upload part of the script:

Code:
$dir = "dir";
if ($file != "") {

if (file_exists("$absolute_path/$file_name")) {
die("The file that you have tried to upload already exists.  Please change the name of the file and try uploading again.<br><br><a href=$backhomeurl>Back to Home</a>");
}

if (($sizelimit == "yes") && ($file_size > $sizebytes)) {
die("The file that you have tried to upload is to big. It must be $sizebytes bytes or less.<br><br><a href=$backhomeurl>Back to Home</a>");
}

$ext = strrchr($file_name,'.');
if (($extlimit == "yes") && (!in_array($ext,$limitedext))) {
die("The file you are uploading doesn't have an acceptable extension.<br><br>It must have one of the following extensions:<br>$exceptedextension<br><br><a href=$backhomeurl>Back to Home</a>");
}



@copy($file, "$absolute_path/$file_name") or die("The file you are trying to upload couldn't be copied to the server<br><br><a href=$backhomeurl>Back to Home</a>");

} else {
die("Must select file to upload<br><br><a href=$backhomeurl>Back to Home</a>");
}
echo "
<html>
<head>
<title>File Uploaded</title>
</head>
<body>";
echo $file_name." was uploaded";
echo "<br>


<br>The url to your file is:<br><br><b><a href=$dl/$file_name>$dl/$file_name</a></b>
<br><br>
<a href=$PHP_SELF?action=upload>Upload Another File</a>


</body>
</html>";
Reply With Quote