Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8647521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:05:38+00:00 2026-06-12T13:05:38+00:00

I generate some xml (actually google kml file) $kml = array(‘<?xml version=1.0 encoding=UTF-8?>’); $kml[]

  • 0

I generate some xml (actually google kml file)

$kml = array('<?xml version="1.0" encoding="UTF-8"?>');
$kml[] = '<kml xmlns="http://earth.google.com/kml/2.1">';
$kml[] = ' <Document>';

I make a string of it

$kmlOutput = implode("\n", $kml); //Join array elements with a string

Then I make an array

$data = array('code' => 'somecode', 'xml' => $kmlOutput);

Then I send my data of cURL

// Setup cURL

$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_POST, true);
//curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 8);
$output = curl_exec($ch);

/**
 * Check for some errors (omitted here)
 */
curl_close($ch);

Upload.php on another server

/* MAIN CODE*/
if ( $_SERVER['REQUEST_METHOD'] === 'POST' ){
    print "\n\n";
    echo "DEBUG: Vardump Post"; 
    var_dump($_POST);
    echo "DEBUG:";
    var_dump($_FILES);

    if ($_FILES["file"]["type"] == "text/xml"  && ($_FILES["file"]["size"] < $maxSize) ){
        if ($_FILES["file"]["error"] > 0){
            echo "Error: (Return Code: " . $_FILES["file"]["error"] . ")<br />";
        } else {
            echo "Code: ".$_POST['key']. "<br />";
            echo "Upload: " . $_FILES["file"]["name"] . "<br />";
            echo "Type: " . $_FILES["file"]["type"] . "<br />";
            echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
            echo "Temp Stored in: " . $_FILES["file"]["tmp_name"]. "<br />"; // temporary copied files disappears when the script ends


            move_uploaded_file($_FILES["file"]["tmp_name"],$dir . $_FILES["file"]["name"]);
            echo "Stored in: " . $dir . $_FILES["file"]["name"];

However the var_dump($_FILES); and even var_dump($_FILES[“code”]); return empty?

-Am I missing something here?
-Can I send two types of data?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:05:42+00:00Added an answer on June 12, 2026 at 1:05 pm

    You can not get it via $_FILES because you are not uploading any file

    To upload a file you need to use @ sign followed by the location of your file

     $data = array('code' => 'somecode', 'xml' => "@". $PATH_TO_XML_FILE);
    

    You can also Just upload directly like this

    curl_setopt($ch, CURLOPT_POSTFIELDS, $kmlOutput);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/xml"));
    

    Example

    $xml =   __DIR__ ."/Pages.xml"; //full part to XML
    $data = array('code' => 'somecode', 'xml' => "@$xml");
    $ch = curl_init($URL);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 8);
    $output = curl_exec($ch);
    echo $output ;
    

    On remote Page

        var_dump($_POST,$_FILES);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some XML files which are used to generate my webpages, however I
I have some php files in a server which generate xml code in them.
I want to generate XML from existing xml but values should come from some
I generate some code using CXF from a WSDL-file. When compiling the code with
I'm trying to generate some XML using XML::Builder, but my element names need to
I'm trying to generate some XML for a jQuery.get (AJAX) call, and I'm getting
I am trying to generate some xml with this php code here... I am
I am working on a project to generate some KML data from our delivery
our system uses some xml files to generate some code. So I've created a
I sadly have a requirement to generate some messy XML. The main document must

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.