Code: Select all
<?php
$uploaddir = $_SERVER['DOCUMENT_ROOT'] . "\\saturnspot"; //replace the $uploaddir to wherever you want the files to go
$filename = $_FILES['file']['name']; // get the filename
$filetype = $_FILES['file']['type']; // get the file MIME type
$uploadfile = $uploaddir . $filename; //this is full path to where the file will go
?>
<HTML>
<HEAD>
<TITLE> SaturnSpot Image Hosting </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></HEAD>
<BODY bgcolor="#000000" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">
<div align="center"><img src="logo.gif" width="277" height="105"> </div>
<table width="90%" border="0" align="center">
<tr>
<td> <p><font color="#FFFFFF"><? if (empty($filename)) { //make sure the user selected a file
echo "Please select a file to upload!";
}
if ($filetype == "image/jpeg" || $filetype == "image/pjpeg" || $filetype == "image/jpg" || $filetype == "image/gif") { //make sure file is .jpg or .gif
if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) { // move the file
echo "Thank you. The files was successfully uploaded.<br><br> To link to this files, please copy the following URL: <b>http://24.197.74.135/saturnspot/$filename</b><br><br>Make sure to copy the URL <b>exactly</b> how it is printed above (filenames are cAsE sensitive).";
}
else {
echo "File upload failed";
}
}
else {
echo " Remember to upload only image files.";
}
?></font></p>
<p><font color="#FFFFFF">To upload images, simply click "Browse"
to search for files locally on your computer. You may only upload 1 file
at a time. Once the file has been successfully uploaded, you will see
a image URL that you can use to directly link to you image. If you have
any questions or comments, please e-mail them to <a href="mailto:97saturnsohc@charter.net">97saturnsohc@charter.net</a>.</font></p></td>
<td><form action="upload.php" method="post" ENCTYPE="multipart/form-data">
<p align="center">
<input type="file" size=40 name="file">
<br>
<input type="hidden" name="MAX_FILE_SIZE" value="250000">
<input type="submit" value="Upload image...">
</p>
</form></td>
</tr>
</table>
</BODY>
</HTML>
?>-----
Thank you. The files was successfully uploaded.
To link to this files, please copy the following URL: http://24.197.74.135/saturnspot/logo.gif
Make sure to copy the URL exactly how it is printed above (filenames are cAsE sensitive).
To upload images, simply click "Browse" to search for files locally on your computer. You may only upload 1 file at a time. Once the file has been successfully uploaded, you will see a image URL that you can use to directly link to you image. If you have any questions or comments, please e-mail them to 97saturnsohc@charter.net.
-----
This is exctly how I want it. No need to change that. Now, here is the problem. If the person doesn't select a file to upload, I want this to appear:
-----
Please select a file to upload!
To upload images, simply click "Browse" to search for files locally on your computer. You may only upload 1 file at a time. Once the file has been successfully uploaded, you will see a image URL that you can use to directly link to you image. If you have any questions or comments, please e-mail them to 97saturnsohc@charter.net.
-----
Instead, I get this:
-----
Please select a file to upload! Remember to upload only image files.
To upload images, simply click "Browse" to search for files locally on your computer. You may only upload 1 file at a time. Once the file has been successfully uploaded, you will see a image URL that you can use to directly link to you image. If you have any questions or comments, please e-mail them to 97saturnsohc@charter.net.
-----
Can someone direct my how how to only allow "Please select a file to upload!" instead of "Please select a file to upload! Remember to upload only image files." without removing the line:
Code: Select all
<?php
else {
echo " Remember to upload only image files.";
}
?>