# In your 'DocumentRoot' directory create a directory
# called tmp.
mkdir tmp
# Change the permissions on this directory so 'others'
# can upload to it.
chmod o+wrx tmp
# Now create a file called up_load.php containing the following code.
<html>
<body>
<?
if (isset($users_file)) {
echo "<B>Remote File Name:</B> $users_file<BR>";
echo "<B>Local File Name:</B> $users_file_name<BR>";
echo "<B>Local File Size:</B> $users_file_size<BR>";
if (isset($users_file_type)) {
echo "<B>Local File Type:</B> $users_file_type<P>"; }
// Change $doc_directory to your 'DocumentRoot'.
$doc_directory = "/www/www.linuxguruz.org/htdocs/";
$my_file = "tmp/uploaded-".$users_file_name;
$copy_path = $doc_directory.$my_file;
if ($users_file != "none") {
if(!copy($users_file, $copy_path)) {
echo "File upload failed!"; }
else { ?><A HREF="<? echo $my_file; ?>">Upload Complete!</A>
<? } }
else { echo "<P>You must select a file to upload!<P>"; ?>
<A HREF="<? echo $PHP_SELF; ?>"><B>Back</B></A> to the Upload Form
<? } }
else { ?>
<form action="<? echo $PHP_SELF; ?>"
enctype="multipart/form-data" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="20000" />
<input type="file" name="users_file" /><br />
<input type="submit" value="Upload!" />
</form><? } ?>
</body>
</html>
# Now point your web browser at http://your.domain.com/up_load.php
Anyone who wishes to make additions or changes to this
PHP Tip email them to webmaster@linuxguruz.org
This document is Copyright (c) 1999, 2000 by LinuxGuruz