OK, I need to code a PHP file that will do the following:
Let the user browse there machine for a picture (or link one);
Max file size / images size;
Make the file name the username with a number.. If I upload one: XinG01 and if I upload another XinG02 and so on...
I have the upload thing at the moment, but thats the only thing... Heres what I got:
PHP Code:
<html><head><title>XinG's Upload script</title></head></html>
<?
if(isset($submit)) {
$target_path = "uploads/";
$filesize = 100000;
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
echo "<br>";
echo "You can see your file at: <a href=\"./$target_path\">HERE</a>";
} else{
echo "There was an error uploading the file, the file is possibly too large!!";
echo "<br>";
echo "The max file size is: $filesize kb";
}
} else {
?>
<form enctype="multipart/form-data" action="<? $_SERVER['PHP_SELF']; ?>" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="<? echo "$filesize"; ?>" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" name="submit" value="Upload File" />
</form>
<br>
View other peoples uploaded files <a href="./uploads/">here!</a>
<?
}
?>
|