note 70503 deleted from function.copy by bobby
| From: | bobby@php.net | Date: | Thu, 19 Oct 2006 14:43:54 +0000 |
| Subject: | note 70503 deleted from function.copy by bobby | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-118764@lists.php.net to get a copy of this message | ||
Note Submitter: info at mihalism dot com
----
This is a simple URL uploader that uses the copy() function it does not include a file size check or
file type check because i dident have the time well here it is
<html><head><title>Simple URL upload copy()</title></html><body
bgcolor='#FFFFFF'><?php
$updir = "url_uploads/"; //storage directory
if(!is_dir($updir))
{
mkdir($updir);
chmod($updir, 0777);
}
if($_GET['option'] == "url_up"){
$nfile = $_POST['nfile']; //post new file name the n is for new
$ofile = $_POST['ofile']; //post old file the o is for old
if(!$nfile)
{
echo "No new file name entered";
exit;
}
elseif(!$ofile)
{
echo "No URL entered";
exit;
}
else
{
//this is a simple upload so we are going to use the copy() function
if(!copy($ofile, $updir.$nfile))
{
echo "Error while uploading please try again";
exit;
}
else
{
echo "File was uploaded to server <br/><br/> Old file <a
href='$ofile'>$ofile</a> <br/> New file <a
href='$updir$nfile'>$nfile</a>";
}
}
}
else
{
echo "Simple URL upload copy() <br/><br/> <form
action='?option=url_up' method='post'>URL to upload : <input
type='text' name='ofile' style='width:250px'><br/>New file
name : <input type='text' name='nfile' style='width:250px'>
<br/><br/> <input type='submit' value='Upload
URL'></form>";
}
?>
</body></html>