Sign in to follow this  
Followers 0
Imbuter2000

fastest way to upload a little (1KB) html file? FTP or HTTP?

4 posts in this topic

I would to frequently upload a little (1KB) frequently-updated html file to my web hosting provider (Hostgator > Linux-based-hosting) from an AutoIT script on my Windows PC.

I've no experience in uploads. The question is: what upload method/technology would be the fastest? FTP or HTTP?

in case of HTTP, what AutoIT function can I use and what do I need to set on the web server to make it accept the upload?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I use FTP as my file storage in uploading 1-10kb txt files.

I use winhttp to do that but you need php code too

Autoit code:

#include "WinHttp.au3"
Global Const $Adres = "website.com"
$subdomain = "uploads/index.php"
$filetxt= (@scriptdir & "\test.txt")
Global $hOpen = _WinHttpOpen()
Global $hConnect = _WinHttpConnect($hOpen, $Adres)
Global $sHTM = _WinHttpSimpleFormFill($hConnect, $subdomain, Default, "name:ufile", $filetxt)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)

php code:

<?php
if (isset($_POST['submit']) && !empty($_FILES["ufile"]) && move_uploaded_file($_FILES['ufile']['tmp_name'], "uploads/".time(). "_".basename($_FILES['ufile']['name']))) {
echo "Done.";
}
?>
<html>
<head>
<title>Upload</title>
</head>
<body>
<form action="index.php" method="post" enctype="multipart/form-data">
Select file: <input name="ufile" type="file" /><br />
<input type="submit" name="submit" value="Upload" />
</form>
</body>

But also there are way uploading it directly to ftp

#include <process.au3>
#include <FTPEx.au3>
Global $host, $user, $pass
;
$host = "ftp.hosting.com" ;can be ip
$user = "username" ; FTP Username
$pass = "password" ; FTP Password
;
Global $file = (@ScriptDir&"/test.txt")

    Global $open = _FTP_Open('MyFTP Control')
ConsoleWrite(@error & "-" & @extended & @CRLF)
If $open Then
$conn = _FTP_Connect($open, $host, $user, $pass, 0, 21)
ConsoleWrite(@error & "-" & @extended & @CRLF)
If $conn Then
$ftpp = _FTP_FilePut($conn, $file, "/htdocs/uploads/test.txt")
ConsoleWrite(@error & "-" & @extended & @CRLF)
If $ftpp Then
_FTP_Close($open)
EndIf
EndIf
EndIf

I think these codes are full of errors but you can make something by yourself

Edited by EdgarT

Share this post


Link to post
Share on other sites

Interesting EdgarP.

With the second (FTP) method it takes about 3 seconds to upload a single tiny 10 bytes long html file.

Is your first method (http?) faster?

Share this post


Link to post
Share on other sites

I think its slower cos I get my file after more than 3secs. Or maybe hosting fault?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0