Anonymous" upload via an FTP Logon [Please Help]

Started by T3CHN0, May 29, 2014, 12:55:07 AM

Previous topic - Next topic

T3CHN0

Hello

I want to allow anyone to upload via an FTP Logon

would be best to look at this first

make [uploads] folder in root directory www.mysite.com/uploads
make file in root called upload.html add following code www.mysite.com/upload.html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<title>Upload a File</title>
</head>
<body>
File Upload<br>
<br>
<br>
<form enctype="multipart/form-data" action="upload.php" method="post">
<input name="MAX_FILE_SIZE" value="100000"
   type="hidden">Choose a file to upload: <input
   name="uploadedfile" type="file"><br>
<br>
Name on Server: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<input maxlength="20" size="20" name="TargetName"><br>
<br>
<input value="Upload File" type="submit">
</form>
</body>
</html>


make file in root called upload.php add following code www.mysite.com/upload.php

<?php
 
// Set up the settings
 // ******
 // ******
 // We can give you a dedicated additional FTP logon just for this ....
 
$ftp_server 'ftp.your-domain.com';
 
$ftpuser 'YourLogon';
 
$ftppass 'YourPassword';
// Capture the file  details from the input form ...
 
$source1 $_FILES['uploadedfile']['tmp_name'];
 
$source2 $_FILES['uploadedfile']['name'];
 
$source_file $source1;
 
// Set the target folder ....
 
$target_dir "uploads/";
 
// Build the full target filename ...
 
$target $target_dir $TargetName;
 
// Connect to the webserver...
 
$conn_id ftp_connect($ftp_server);
 
// Login with username and password
 
$login_result ftp_login($conn_id$ftpuser$ftppass);
 
// Check connection
 
if ((!$conn_id) || (!$login_result)) {
         print (
"FTP connection has failed!<BR>");
         print (
"Attempted to connect to " $ftp_server " for user " $ftpuser ."<BR>");
         exit;
     } else {
         print (
"Connected to " $ftp_server ", for user " $ftpuser "<BR>");
     }
 
// Upload the file .....
 
$upload ftp_put($conn_id$target$source_fileFTP_ASCII); 
 
// Check upload status
 
if (!$upload) {
         print (
"FTP upload has failed! <BR>");
     } else {
         print (
$source2 " Uploaded as " $target "<BR>");
         print (
"Upload OK <BR>");
     }
 
// Close the connection ...
 
ftp_close($conn_id);
 print (
"Exiting ...<BR>");
 
?>




I try this but get connection error

Have a look at my url http://toyotatarago.net/upload.html

Would someone be able to make a mod for this???  I want a mod that simply uploads images document and DIY videos [or simply .zip file only] > THAT NO ONE CAN SEE ONLY UPLOAD TO.
OR tell me what is wrong as to why ftp does not work for me!.

Yes FTP user and password is setup and works with FTP software if anyone was going to ask
and yes the FTP details are for access to a folder called uploads I want to upload to.

Sir Osis of Liver

You don't need ftp to do a php upload -



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

<head>
<script type="text/javascript">
function goBack()
{
window.history.back()
}
</script>
</head>

<body bgcolor="#C0C0FE" text="#000000" link="#00ff00" vlink="#00ff00" alink="#00ff00">

<div style='font-size:16px; font-family:comic sans ms'>

<br><br><br><br>
<center>

<?php 

$target 
"uploads/"
$target $target basename$_FILES['uploaded']['name']) ; 
$uploaded_name basename$_FILES['uploaded']['name']) ; 
$uploaded_type $_FILES['uploaded']['type'];
$uploaded_size $_FILES['uploaded']['size'];

$ok=1

if (
$uploaded_size 2000000)

echo 
"Your file is too large - 2MB max.<br><br>"
$ok=0
}

if (
$uploaded_name==""

echo 
"Please select a file to upload.<br><br>"
$ok=0;
$duh=1
}
else

if ((
$uploaded_type != "image/x-png")
&& (
$uploaded_type != "image/png")
&& (
$uploaded_type != "image/gif")
&& (
$uploaded_type != "image/bmp")
&& (
$uploaded_type != "image/jpeg")
&& (
$uploaded_type != "image/pjpeg")
&& (
$uploaded_type != "audio/mpeg")
&& (
$uploaded_type != "audio/x-mpeg")
&& (
$uploaded_type != "audio/mp3")
&& (
$uploaded_type != "audio/x-mp3")
&& (
$uploaded_type != "audio/mpeg3")
&& (
$uploaded_type != "audio/x-mpeg3")
&& (
$uploaded_type != "audio/mpg")
&& (
$uploaded_type != "audio/x-mpg")
&& (
$uploaded_type != "audio/x-mpegaudio")
&& (
$uploaded_type != "audio/x-amzaudio")
&& (
$uploaded_type != "video/x-ms-wmv")
&& (
$uploaded_type != "video/avi"))

{
echo 
"File type &nbsp<b><font face='arial'>" $uploaded_type "</font></b>&nbsp is not allowed." "<br><br>";
$ok=0;
}

if ((
$ok==0)
&& (
$duh!=1))

echo 
"Sorry, your file was not uploaded."


else

if ((
$ok!=0)
&& (
$duh!=1))

{
if(
move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) 
{
echo 
"Your file has been uploaded to - <br><br>";
echo 
"<span style='font-size:12px; font-family:arial'>http://www.mysite.com/uploads/" "<b>" $uploaded_name "</b></span><br><br>";

mail('[email protected]''File upload''Mysite has uploaded ' $uploaded_name);



else
{
if (
$duh!=1)
{
echo 
"Sorry, there was a problem uploading your file.<br><br>";
}
}
}


?>


<br><br><br>
<input type="button" value="Back" onclick="goBack()" />

</center>

</div>

</body>
</html>



Probably not very secure, but been using it for years on several boards.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

T3CHN0

thanks

How does it work?
I made a test.html and I see a light blue blank window.
how do I select a file to upload and how does it know what folder on my doamin to upload to

T3CHN0

I have been trying to find away to do this for about a week, I thought I would come here ans ask
for help because I just was not finding my answer.

I came across this flash version tonight and it works so good OMG i am happy.
no need for ftp user accounts nothing.

just upload the Flash Version to it's own folder on your domain
create another folder called uploads.
then go to www.yourdomain.com/flashfolder and the page will open with flash demo in big writing
select your file and it starts uploading automatically and your done.

sweet. I wanted to share this for everyone to be able to find this info and use the flash player.
I might even buy the HTML version to test it out.

riou

Quote from: T3CHN0 on May 29, 2014, 03:52:07 AM
thanks

How does it work?
I made a test.html and I see a light blue blank window.
how do I select a file to upload and how does it know what folder on my doamin to upload to


The code Krash put is for a PHP file, .html wouldn't show anything as it doesn't run php code, the folder in his example was the $target = part at the top of the php start block

T3CHN0

arr yes I tested that and it partly works.
in text it says
QuotePlease select a file to upload
but no button to brows for a file or to select a file.
but there is a working button to go BACK.

Be interested to know what needs to be edited to make it work.

I like the other way I am using but if this way works as well I would like to see it working.
maybe I will use this way instead. 

Sir Osis of Liver

Here's the other bits, including the frontend.  Use what you need.

upload.htm -



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

<head>
<title>Forum</title>

<script type="text/javascript">
function goBack()
{
window.history.back()
}
</script>

</head>


<body bgcolor="#C0C0FE" text="#000000" link="#00ff00" vlink="#00ff00" alink="#00ff00" onLoad="focus()">

<div align="center" style="margin-top: 20px;">
<span style="font-size:12px; font-family:arial;">Forum</span>
<br>
<span style="font-size:16px; font-family:comic sans ms"><u>Upload a file</u>
<br><br>

<form enctype="multipart/form-data" action="upload.php" method="POST">
<input name="uploaded" type="file" size=60 maxlength=200 style="background-color:#ffffff;">
<br><br>
<input type="submit" value="Upload">
</form>
</div>
<br>
<table width=75% border="0" align="center">
<tr>

<td width="5%"></td>

<td>
<div style="font-size:13px; font-family:comic sans ms;">
<span style="font-weight: bold; line-height: 30px; color: red;"> &nbsp Maximum file size - 2MB</span>
<br>
<span style="font-weight: bold;"> &nbsp File names -</span>
<ul style="margin-top: 5px;">
<li>Are case sensitive
<li>Must not contain spaces
<li>Must not contain punctuation, except hyphen "-" and underscore "_"
<li>Must not contain special characters (@,#,%,&, etc.)
</ul>
</div>
</td></tr>

<tr><td colspan="2" align="center">
<br>
<input type="button" value="File List" onclick="window.location.href='uplist.php'">
<span style="font-size:10"><br><br></span>
<input type="button" value="Close" onclick="window.self.close()" />

</td></tr>

</table>

</body>



uplist.php -



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

<head>
<script type="text/javascript">
function goBack()
{
window.history.back()
}
</script>
</head>

<body bgcolor="#C0C0FE" text="#000000" link="#00ff00" vlink="#00ff00" alink="#00ff00">

<br>
<center><span style='font-size:16px; font-family:comic sans ms'><u>File List</u></span></center>
<br>

<table width="85%" border="0" align="center">
<tr><td>

<?php

$dir 
= @ dir("uploads");

while ((
$file $dir->read()) !== false)

if ((
$file != ".")
&& (
$file != ".."))

{
echo 
"<span style='font-size:12px; font-family:arial'>http://www.domain.com/forum/uploads/" "<b>" $file "</b></span><br />";
}

$dir->close();


?>


</td></tr>
</table>

<br>

<center>
<input type="button" value="Back" onclick="goBack()" />
</center>

<br>

</body>
</html>



uploadif.htm -



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

<body bgcolor="#d7d7d7" text="#000000" link="#00ff00" vlink="#00ff00" alink="#00ff00">

<br><br><br><br><br>
<center>
<iframe src="upload.htm" width="620" height="450" scrolling="auto"></iframe>
</center>
</body>
</html>



The code I posted previously is upload.php.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

T3CHN0

Thanks for that, that's great

I like the way this one looks and it want's to work but I keep getting error
QuoteSorry, there was a problem uploading your file.
I have changed all the mydomain.com lines to my site but there must be something I am not looking at.

T3CHN0

#8
never mind I got it working. I found I had to put another folder inside my upload folder called uploads.
I had the uploads folder called uploads outside the folder in the same root directory as the forum.

Now I just need to work out why file list isn't working.

Also I noticed there is no progress meter to indicate how far the download has left.
is that something easy to add?

I LOVE how this upload sends me an email as well, that's great.

P.S.
Okay so I got it all working now.

Things I would like to change

Are case sensitive / doesn't matter because most people will still try before they read
Must not contain spaces / doesn't matter because most people will still try before they read
File Size / I want it set to 1Gb MAX

Some kind of progress meter is the most important, large files tend to lead people to think
something is not right and close the window to try again.

Can you help me with any of that? It would be very appreciated if you could. cheers.


Sir Osis of Liver

You can edit upload.htm to change/remove the comments about file names.  Tends to vary with server, anyway. 

To change max filesize, that's in upload.php -



if ($uploaded_size > 2000000)
{
echo "Your file is too large - 2MB max.<br><br>";
$ok=0;
}



Most host servers will timeout the script before you can upload 1 gig, but give it a try.  You may also have to change upload settings in php.ini on your server.

Never tried adding a progress bar, browser status bar shows one.  Will take a look if I get some time tonight, but don't think it's easy.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

T3CHN0

Sweet ty

and the progress bar, if you look at the url I added up the top there, that way has a progress bar but
doesn't send me an email to let me know a file was uploaded and doesn't have a list files option.

if somehow both mods could to be combined into 1, it would be the best of both worlds.

and uploadilfy will except any size, I already uploaded a 800mb file to test it.

Advertisement: