Web Hosting Talk







View Full Version : urgent uploading


mcplamen
11-02-2004, 03:31 AM
I need a simple upload script in order to upload pics. I know there are a lot of on the web, but I'm in hurry and
most of them are too complicated.
I don't want to resize or rename picture, I just want to upload it using "file" field in the form.
Thank you in advance and I'll appreciate your help

Alan @ CIT
11-02-2004, 05:36 AM
What scripting language do you want it in? PHP? Perl? ASP?

mcplamen
11-02-2004, 09:55 AM
I'm sorry about language, PHP is the language

cow_helmet
11-02-2004, 01:47 PM
Super simple example:


<?php
if (isset($_POST['upload'])) {
move_uploaded_file($_FILES['uploadFile']['tmp_name'], "./{$_FILES['uploadFile']['name']}");
}
$c = "";
$dir = dir("./");
while ($filename = $dir->read()) {
if ($filename == "." || $filename == "..") {
continue;
}
$c .= "<a href=\"$filename\">$filename</a><br />";
}
?>
<html>
<head>
<title>My Little File Uploader</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
<input type="file" name="uploadFile" />
<br />
<input type="submit" name="upload" value="Upload" />
</form>
<?php echo $c; ?>
</body>
</html>