PDA

View Full Version : Uploading to External Server


kompakt
01-04-2005, 04:18 AM
I'm trying to find a script that will allow uploading files to an external server, different from where the forum is installed. It will be an IIS server on a personal computer with 400gigz of space. There was a similar hack installed on vb2.

Thanks...

kompakt
01-10-2005, 04:19 PM
bump... any ideas?

scotty
01-10-2005, 08:23 PM
this is the script I'm using to transfer my avatars to a different server - maybe that would be helpfull...

<?php
$FTP_HOST ="www.YOURDOMAIN.com";
$FTP_USER ="YOURUSERNAME";
$FTP_PW ="YOURPASSWORD";
$FTP_ROOT_DIR="/";
$LOCAL_SERVER_DIR = "avatars/";
$FTP_DIR = "REMOTE/DRICTORY";
$handle=opendir($LOCAL_SERVER_DIR);
while (($file = readdir($handle))!==false)
{
if(!is_dir($file)){
$f[]="$file";
}
}
closedir($handle);
sort($f);
$count=0;
$mode = FTP_BINARY;
$conn_id = ftp_connect($FTP_HOST);
if(ftp_login($conn_id, $FTP_USER, $FTP_PW)){
print "from: ".$LOCAL_SERVER_DIR."<br>";
print "to: ".$FTP_HOST.$FTP_ROOT_DIR.$FTP_DIR."<br>";
ftp_pwd($conn_id);
ftp_chdir($conn_id,$FTP_DIR);
foreach($f as $files) {
$from = fopen($LOCAL_SERVER_DIR.$files,"r");
if(ftp_fput($conn_id, $files, $from, $mode)){
$count +=1;
// print $files."<br>";
}
}
ftp_quit($conn_id);
}
print "upload : $count files.";
?>

this script is scheduled by the admincp/cron once an hour.

scotty

kompakt
01-11-2005, 01:35 AM
Thanks, I can see what your script does. The problem with this is that the attachments do not upload to the forum server as individual static files. So copying them to an external server might not do the trick. I'll need to embed this into the upload script somehow.

Marco van Herwaarden
01-11-2005, 03:25 AM
How do you mean they not upload as individual files?

kompakt
01-12-2005, 12:14 AM
Yes they do Marco. But they dont save as individual files on the server. The attachments have their own way of storage. I looked at the folder where they save to and it looks like this:

\attach\1\...9\

All the files are named ####.attach on the server. But within the forum, each file shows the origional attachment name as uploaded (.jpg, .txt, .mp3)

deathemperor
01-12-2005, 06:27 AM
the attachments are stored in the database, not in your storage.
thanks scotty for the script. You give me the idea how to upload from a server to another.

edit: it's possible to query a remote server from the local one, that way you can store attachment in your desired server and it's still use the database. but this requires a lot of changes I think.

Marco van Herwaarden
01-12-2005, 06:33 AM
@deathemperor

Well vB give you the choice where to store them, in the database or in the filesystem.

@kompakt
They DO save as individual files if stored on filesystem. they are however not named the same as teh attachment. Wanted to research how to relate a filename on filesystem back to the attachment name, but never found time for doing so, but i guess others already have.

deathemperor
01-12-2005, 07:08 AM
oh I thought I've seen it somewhere in vboptions ^^ but I was not sure.

by either way you have solutions...

Marco van Herwaarden
01-12-2005, 07:25 AM
oh I thought I've seen it somewhere in vboptions ^^ but I was not sure.

by either way you have solutions...
You can find this setting in ACP-->Attachments-->Attachment Storage Type

You can choose to store all your attachments in database or filesystem.

And no, i didn't give a solution.

deathemperor
01-12-2005, 12:10 PM
thanks you for pointing it out, I guess I knew every part of my ACP already ^^.

if you want to move those attachments store in db, you have my idea. otherwise you have the script posted by scotty, it has to be modified though.

what else ?

kompakt
01-12-2005, 03:39 PM
How will storing them in the filesystem effect the bandwith?

kompakt
01-12-2005, 03:43 PM
edit: it's possible to query a remote server from the local one, that way you can store attachment in your desired server and it's still use the database. but this requires a lot of changes I think.

This is what I'm looking for. How about storing them on the filesystem of the remote server? Would that make it easier than using them in the database?

Thanks for trying to help guys...

tnguy3n
01-13-2005, 08:37 PM
This is what I'm looking for. How about storing them on the filesystem of the remote server? Would that make it easier than using them in the database?

Thanks for trying to help guys...
I got this feature in my new Image/File Uploader, but i ain't release it for free. :P