Php posting help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Php posting help
# 1  
Old 10-11-2011
Php posting help

Hello unix.com

I want to use curl to post some logs to a remote server using curl.

PHP Code:
$ch curl_init("http://example.com/post/post.php");

curl_setopt($chCURLOPT_POST      ,1);
curl_setopt($chCURLOPT_POSTFIELDS    ,"FOUT=hash.gif&DATA=$message");
curl_setopt($chCURLOPT_HEADER      ,0);  // DO NOT RETURN HTTP HEADERS
curl_setopt($chCURLOPT_RETURNTRANSFER  ,1);  // RETURN THE CONTENTS OF THE CALL
$Rec_Data curl_exec($ch); 
What should post.php contain so can the script create the file and post the data into it?
# 2  
Old 10-11-2011
Something like:

Code:
<?php
        if(isset($_POST['FOUT']))
        {
                $fp=fopen($_POST['FOUT']);
                fwrite($fp, $_POST['DATA']);
                fclose($fp);
        } ?>

I haven't tested this. I also haven't decoded however you translated the binary data of the message into ASCII text. It'll just dump it into the file as-is.
# 3  
Old 10-11-2011
I'll test it right away and come back.

---------- Post updated at 06:11 PM ---------- Previous update was at 06:02 PM ----------

It doesnt work... The file isnt created on the remote host.

Any ideas?

Last edited by galford; 10-11-2011 at 08:23 PM..
# 4  
Old 10-12-2011
Check the return values of all the calls. Tell us any error messages you get. We can't see your computer from here.

The web server needs permissions to write to that particular directory to write to it. If you haven't given it permissions, it doesn't have them.

Code:
chown :apache /path/to/dir/
chmod g+w /path/to/dir/

# 5  
Old 10-12-2011
You should base64_encode() and then urlencode() the binary data to prevent data corruption.
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. What is on Your Mind?

Saturday May 4th the Forums Will Briefly Break Testing PHP 5.6 to PHP 7.0

On Saturday May 4th the forums will briefly break when I switch our Apache PHP 5.6 module to PHP 7.0. Previously, I had two sites set up for testing the migration, but for many reasons, the second site has additional issues unrelated to PHP 7.0 so it is hard to debug on a different site and... (3 Replies)
Discussion started by: Neo
3 Replies

2. Red Hat

Update php 4.3 RPM to php 5.3.3 php

Dear All, My redhat version is: # cat /etc/redhat-release Red Hat Enterprise Linux AS release 4 (Nahant Update 4) # # uname -a Linux cotapplication3.cot.com 2.6.9-42.ELsmp #1 SMP Wed Jul 12 23:32:02 EDT 2006 x86_64 x86_64 x86_64 GNU/Linux # I want to update my php from: # php... (1 Reply)
Discussion started by: monojcool
1 Replies

3. UNIX for Advanced & Expert Users

Running multiple php scripts into one php only, cron mail alert problem...

hi, while separated they produce the usual mail alert and i can see the output... if i write into the php script: <?php system('php -f /var/www/vhosts/domain.com/httpdocs/folder/script1.php'); system('php -f /var/www/vhosts/domain.com/httpdocs/folder/script2.php'); system('php -f... (0 Replies)
Discussion started by: 7stars
0 Replies

4. Web Development

I can't open my index.php page after insert php code

Hello guys, Does anyone can help me? I've just made my simple index.php without any code, but after insert session code to check if any user is authenticated, my index.php doesn't work anymore. Any fresh eyes could help me to see what and where the code is wrong? <? if... (6 Replies)
Discussion started by: metalfreakbr
6 Replies

5. Post Here to Contact Site Administrators and Moderators

Firefox 3.03 posting a newthread.php error

I ran some updates on my ubuntu hardy distro and after the running the updates I noticed that any website that is using PHP I cannot submit any thread. It gives a message saying,"opening newthread.php" and asks me where I want to save the php page. I know this is a bug and have read many items on... (11 Replies)
Discussion started by: metallica1973
11 Replies
Login or Register to Ask a Question