Alright, I have 2 things I need help with. First one has to do with this code:
<FORM ENCTYPE="multipart/form-data" ACTION="upload.php" METHOD="POST">
The file: <INPUT TYPE="file" NAME="userfile">
<INPUT TYPE="submit" VALUE="Upload">
</FORM>
<?php
$path = "test/";
$max_size = 10000000;
if (!isset($HTTP_POST_FILES['userfile'])) exit;
if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) {
if ($HTTP_POST_FILES['userfile']['size']>$max_size) { echo "The file is too big<br>
"; exit; }
if (($HTTP_POST_FILES['userfile']['type']=="image/gif") || ($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/jpeg")) {
if (file_exists($path . $HTTP_POST_FILES['userfile']['name'])) { echo "The file already exists<br>
"; exit; }
$res = copy($HTTP_POST_FILES['userfile']['tmp_name'], $path .
$HTTP_POST_FILES['userfile']['name']);
if (!$res) { echo "upload failed!<br>
"; exit; } else { echo "upload sucessful<br>
"; }
echo "File Name: ".$HTTP_POST_FILES['userfile']['name']."<br>
";
echo "File Size: ".$HTTP_POST_FILES['userfile']['size']." bytes<br>
";
echo "File Type: ".$HTTP_POST_FILES['userfile']['type']."<br>
";
} else { echo "Wrong file type<br>
"; exit; }
}
?>
Look at it here…
I want to add a feild for the user to enter their name and I want the name they enter to add onto the front of the file name they are uploading.
**Next;
**I need help displaying the images that are uploaded in 2 columns, I can only get 1 columb/row. Here is the code for that:
<?
/* This script displays all the images in the current directory. Written
* by Sander Spek <s@sander-s.net>. This script has been copylefted, and
* falls under the GNU General Public License
* <http://www.gnu.org/copyleft/gpl.html>.
*/
// The RegExp for finding images.
$fileregex = "[jpg|jpeg|png|gif]";
// We use the current folder.
$all = opendir('test');
// Create the array containing the image references.
$photos = array();
// Fill the array:
while ($file = readdir($all)) {
if (!is_dir($location.'/'.$file) and $file <> ".." and $file <> ".") {
if (preg_match($fileregex,strtolower($file))) {
array_push($photos,$file);
}
}
}
// Let's see how many image references we retrieved.
$arlength = count($photos);
echo "Contents: ".$arlength;
// And finally, let's display our stuff.
for ($i=0; $i<$arlength; $i++) {
echo '<table width="200" border="0" cellspacing="5" cellpadding="0">
<tr>
<th scope="col" height="150" background="test/'.$photos[$i].'" /><a href="test/'.$photos[$i].'"><img src="inviz.gif" border="0" height="150" width="200"></a></th>
</tr>
</table>';
}
?>