Uploading File In A Different Server

Started on the old forum in April 2009 · view the original in the archive · old links redirect here

13 replies · 1,098 views · started 17 years ago · 1 min read

11 participants
rainforest Newbie · 4 posts #1

Hello

suppose ive a site named domain.com now i want my members to upload their files to a different site like test.com.I meant the files only will be copied to the site test.com but the informations of that file and user will be sent to the database of domain.com .How to do that?

ive tried by changing the permission of test.com to 777 bt it still showing

'that site doesnt allow writeable connections.couldnt copy the file'

Anyone to help..? thanks

ori Lead · 512 posts #2

all i can say is if u somehow find a way DONT DO IT hackers will easily be able 2 upload files to ur server then lol

Anshul Senior · 296 posts #3

rainforest wrote: Hello

suppose ive a site named domain.com now i want my members to upload their files to a different site like test.com.I meant the files only will be copied to the site test.com but the informations of that file and user will be sent to the database of domain.com .How to do that?

ive tried by changing the permission of test.com to 777 bt it still showing

'that site doesnt allow writeable connections.couldnt copy the file'

Anyone to help..? thanks

yes u can do it ask your domain.com host for database details if u wanna operate it from other site . then connect ur database of domain.com from test.com

subzero Super moderator Fellow · 3,954 posts #5

if you making a file host with diff mirrors you can do it by password or a set key with forse headers to stop it showin where you put it

like this

uploaded to one host then you uploaded to all cpanel

domain1 domain2 domain3

so when a user download it he or she can pick what data speed she likes

abit like rapidshare ??

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

something else Fellow · 2,296 posts #6

rainforest wrote: Hello

suppose ive a site named domain.com now i want my members to upload their files to a different site like test.com.I meant the files only will be copied to the site test.com but the informations of that file and user will be sent to the database of domain.com .How to do that?

ive tried by changing the permission of test.com to 777 bt it still showing

'that site doesnt allow writeable connections.couldnt copy the file'

Anyone to help..? thanks

I Can Create A Safe Uploading System That Uploads To (Domain B ) Without Leaving (Domain A ). But (Domain B ) Has To Be A Decent Server.

The Only Question Is It worth Me Coding It For Free?*:p lol

GumSlone Administrator Principal · 1,690 posts #7

you can try this class: http://www.phpclasses.org/browse/package/3753.html i havent tested it but it uses curl ant it is the best way to upload files to other servers.

and here is a simple example:

<form action="curlupload.php" method="post" enctype="multipart/form-data">
<div>
<label for="upload">Select file</label>
<input name="upload" type="file" />
<input type="submit" name="Submit" value="Upload" />
</div>
</form>
if (isset($_POST['Submit'])) {
 if (!empty($_FILES['upload']['name'])) {
 	$ch = curl_init();
 	$localfile = $_FILES['upload']['tmp_name'];
 	$fp = fopen($localfile, 'r');
 	curl_setopt($ch, CURLOPT_URL, 'ftp://ftp_login:password@ftp.domain.com/'.$_FILES['upload']['name']);
 	curl_setopt($ch, CURLOPT_UPLOAD, 1);
 	curl_setopt($ch, CURLOPT_INFILE, $fp);
 	curl_setopt($ch, CURLOPT_INFILESIZE, filesize($localfile));
 	curl_exec ($ch);
 	$error_no = curl_errno($ch);
 	curl_close ($ch);
        if ($error_no == 0) {
        	$error = 'File uploaded succesfully.';
        } else {
        	$error = 'File upload error.';
        }
 } else {
    	$error = 'Please select a file.';
 }
}

copy and paste from: http://www.web-development-blog.com/archives/tutorial-ftp-upload-via-curl/

and if you need more examples or tips you can try this link: http://www.google.com/search?hl=en&q=php+curl+file+upload&aq=0&oq=php+curl+file

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

metulj Super moderator Principal · 1,726 posts #8

Anshul wrote: yes u can do it ask your domain.com host for database details if u wanna operate it from other site . then connect ur database of domain.com from test.com

a bit offtopic question... but still...

only host can give out database details? is there any other way to get details?

It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt. ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ ! ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.

キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!

Anshul Senior · 296 posts #9

metulj wrote: a bit offtopic question... but still...

only host can give out database details? is there any other way to get details?

yep you can ask from your host about it

instead of localhost you need to write $DB_HOST = "localhost";

wat your host tell you like in freehostia database host is somethink like this $DB_HOST = "mysql.freehotia.com";

something else Fellow · 2,296 posts #10

Anshul wrote: yep you can ask from your host about it

instead of localhost you need to write $DB_HOST = "localhost";

wat your host tell you like in freehostia database host is somethink like this $DB_HOST = "mysql.freehotia.com";

I Thought There is a code you have to place in your database to except external server ip number. (because of security issues) I cant remember what the code is tho lol

(apart from on freehostia)

Anshul Senior · 296 posts #11

something else wrote: I Thought There is a code you have to place in your database to except external server ip number. (because of security issues) I cant remember what the code is tho lol

(apart from on freehostia)

Remote Database Access Hosts

You can allow external web servers to access your MySQL databases by adding their domain name to the list of hosts that are able to access databases on your web site. Add Access Host

Host (% wildcard is allowed):

rukiya Lead · 569 posts #12

Many hosts dont allow curl functions So I do like this

<?php
function rukiyaupload($from,$to)
{
if(!@copy($from,$to))
{
    $errors= error_get_last();
    echo "UPLOAD ERROR: ".$errors['type'];
    echo "<br />\n".$errors['message'];
} else {
    echo "File uploaded from $from successfully!";
}
}

rukiyaupload('http://www.example.com/somefile.zip','./somefile.zip'));
?>

or

<?php 
$file = "http://www.example.com/sample.zip"; 
$f = explode("/",$file); 
$end = end($f); 
file_put_contents($end, file_get_contents($file));
?>
ksg91 Developer · 162 posts #13

you can do it by connecting to remote database.

in database connection, set host address of the database with its details. so all of your queries will be fired on that db

Follow me @ksg91 | My Blog: http://ksg91.com | Nokia Blog: http://NokiaTips.in

Mysterio Lead · 630 posts #14

Why all this tired work and messed code? Why not upload to domain.com and immediately transfer to test.com, then delete the file? I would do this.

mysterio.al - programming is a functional art

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close