cURL

Status
Not open for further replies.

vol7ron

New Member
Messages
434
Reaction score
0
Points
0
yeah with that information... im not sure anyone is going to help.
 

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
Ok I edited a bit and managed to get some reactions:

PHP:
<html>
<head>
</head>
<body>
<?

if (!isset($_POST['file'])){
    ?>
<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" id="form"  method="post" style="display: inline;">
    Max filesize: <b>100 MB</b><br />
         <table border=0 cellspacing=0 cellpadding=2><tr><td align=center colspan=2>
     <input type="file" name="upfile" size="50" style="background-color:#EEE" /></td></tr>
         <tr><td align=left>
         <tr><td align=center colspan=2></td></tr></table>
    <p><center><input type="submit" value="Upload!" id="upload" name="file" /></center>
    </form>
    </body>
    </html>


<?php
} else {
/* [url]http://localhost/upload.php:[/url]
print_r($_POST);
print_r($_FILES); */


$ch = curl_init();

//$data = array('name' => 'Foo', 'file' => '@C:\Users\vigge_sWe\Desktop\template\template\style.css');

curl_setopt($ch, CURLOPT_URL, 'http://datashelf.net/upload.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $_FILES['upfile']);

curl_exec($ch);
}
?>

upload.php reports "You didn't pick a file to upload"
 
Last edited:

tttony

Member
Messages
147
Reaction score
0
Points
16
I dont see this on your code:

PHP:
// you have put the dir file in your case is the tmp dir
// or try ie: http://domain.com/file.ext
$data = array('name' => 'Foo', 'file' => '@/home/user/test.png');

// pass the data
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

try and tell me...
 
Last edited:

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
I dont see this on your code:

PHP:
// you have put the dir file in your case is the tmp dir
$data = array('name' => 'Foo', 'file' => '@/home/user/test.png');

// pass the data
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
try and tell me...

Because that is irrelevant. I am not trying to upload a file on server1.

Think rapidshare.

I want to upload $_FILES['upfile'], not a local file
 
Last edited:

tttony

Member
Messages
147
Reaction score
0
Points
16
the problem is that upload.php is recursive, you need other script.php to do something... or you can use a variable ie:

curl_setopt($ch, CURLOPT_URL, 'http://localhost/upload.php?save_file');

do you know I mean??
 

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
well, cURL seem to not be able to send data, because it never leaves my computer. I used php.net's example files, it did not work.

I sen't $data to test.php that var dumped $data and got NULL
 
Last edited:

brunoais

New Member
Messages
115
Reaction score
0
Points
0
try using this part of coding:
you should change "url of file to be downloaded to the server" to the actual url
PHP:
curl_setopt($ch, CURLOPT_URL,"url of file to be downloaded to the server");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 


$result= curl_exec($ch);
this will download the code from the site:
you'll assign
and assign it to
$result
see if this is what you want
now you may use:
PHP:
$datei = fopen("http://datashelf.net/upload.php", "w");
fwrite($datei, $result);
fclose($datei);
to create the file and write the whole data

If you need more help just ask, if I was useful please increase my reputation
 
Last edited:

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
try using this part of coding:
you should change "url of file to be downloaded to the server" to the actual url
PHP:
curl_setopt($ch, CURLOPT_URL,"url of file to be downloaded to the server");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 


$result= curl_exec($ch);
this will download the code from the site:
you'll assign
and assign it to
$result
see if this is what you want
now you may use:
PHP:
$datei = fopen("http://datashelf.net/upload.php", "w");
fwrite($datei, $result);
fclose($datei);
to create the file and write the whole data

If you need more help just ask, if I was useful please increase my reputation

Wouldn't that download a page and write it to the upload.php file? I want to upload a file with upload.php from another server without fopen.

Anyway, vol7ron is fixing it for me, probably
 

brunoais

New Member
Messages
115
Reaction score
0
Points
0
I only know to do that without fopen is to use server() but it is desactivated most of the time (only advanced php has it but it is only allowed for short periuds)
 

tttony

Member
Messages
147
Reaction score
0
Points
16
test with this files and tell me...

on send-file.php there is a description...
 

Attachments

  • curl-test.rar
    2.1 KB · Views: 5

vol7ron

New Member
Messages
434
Reaction score
0
Points
0
i'm out of town, but i found a computer here with decent internet connection, so try what tttony said and let us know
 
Status
Not open for further replies.
Top