Creating FTP upload page

  • Thread starter Thread starter Anonymous
  • Start date Start date
A

Anonymous

Guest
Why don't you just use a regular copy process ? :?

$source_file (Its the the uploading input)
Code:
<?
$path="path to directory";
$max_size=1000000;
$source_file_size_kb=(int)($source_file_size/1000);
if(is_uploaded_file($source_file)){
if($source_file_size>$max_size){
print "<font color=red><b>ERROR</b>:</font> The File's Size Is More Then <b>1Mb</b>!<br>"; exit;}
if($source_file_type=="text/html" || $source_file_type=="application/octet-stream"){
print "<font color=red><b>ERROR</b>:</font> You Are <b>Not</b> Allowed To Upload This Type Of File!<br><br>"; exit;}
$do=copy($source_file, $path . $source_file_name);
if($do){
print "<font color=red><b>Name</b>:</font> $source_file_name<br>";
print "<font color=red><b>URL</b>:</font> $http://.../$source_file_name<br>";
print "<font color=red><b>Size</b>:</font> $source_file_size_kb KB <br>";
print "<font color=red><b>Type</b>:</font> $source_file_type<br><br>";
if($source_file_type=="image/gif" || $source_file_type=="image/jpg" || $source_file_type=="image/jpeg" || $source_file_type=="image/bmp"){
print "<u><b>Picture Preview</b></u><br><br>";
print "<img border=0 src=http://.../$source_file_name><br><br><br>";
}
}
elseif(!$do){
print "<font color=red><b>ERROR</b>:</font> Uploading Failed! Please Try Again Or Email The <b>Webmaster</b>.<br><br>";
}
}
?>
 
Explanation:
:arrow: You can set max size for the uploaded files - 100000 = 1MB.
:arrow: If the file that you want to upload is bigger then 1MB it will show an error.
:arrow: You can set type of files that are not allowed to be uploaded - html,asp...
:arrow: You tell the code what to do after the file is uploaded - here it shows it's name... url... size and type and if its an image file, then it will preview the image to the user...

Very Easy To Understand :P

:idea: You need to set a form...

<form method="POST" action="">
<input type="file" name="source_file" value="<?=$source_file?>">
<br>
<input type="submit" name="upload" value="Upload">
</form>
 
For $59 you can buy the dreamweaver extension 'pure php upload'. It does exactly what you want (I think), but you need to use Dreamweaver (MX). See this site: http://www.dmxzone.com/ShowDetail.asp?NewsId=4509.
 
Lol... I have Dreamweaver MX, what is it exactly you were talking about anyway?
 
It's an extension, meaning that you can download and install it with ease, and then it will integrate in Dreamweaver as if it was pre-installed. I've been looking for an option to do php uploading, and found this extension. I haven't bought it (yet), but it seems to be a very easy and usefull one. You can find more information at the website I gave.
 
Are you talking about the code that I'v writed :?:
By the way the form and the code has to be in the same page...
Do this :arrow:

<form>
.....
</form>
<?
....
?>
 
Back
Top