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 8182299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:49:08+00:00 2026-06-07T00:49:08+00:00

I am indexing the file using php curl library. I am stuck here with

  • 0

I am indexing the file using php curl library. I am stuck here with the code

echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
     $result=move_uploaded_file($_FILES["file"]["tmp_name"],"upload/" . $_FILES["file"]["name"]);
     if ($result == 1) echo "<p>Upload done .</p>";
        $options = getopt("f:");
        $infile = $options['f'];

        $url = "http://localhost:8983/solr/update/";
        $filename = "upload/" . $_FILES["file"]["name"];
        $handle = fopen($filename, "rb");
        $contents = fread($handle, filesize($filename));
        fclose($handle);
        echo $url;
        $post_string = file_get_contents("upload/" . $_FILES["file"]["name"]);
        echo $contents;
        $header = array("Content-type:text/xml; charset=utf-8");

        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
        curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
        curl_setopt($ch, CURLINFO_HEADER_OUT, 1);

        $data = curl_exec($ch);

        if (curl_errno($ch)) {
           print "curl_error:" . curl_error($ch);
        } else {
           curl_close($ch);
           print "curl exited okay\n";
           echo "Data returned...\n";
           echo "------------------------------------\n";
           echo $data;
           echo "------------------------------------\n";
        }

Nothing is showing as a result. Moreover there is nothing shown in the event log of Apache Solr.
please help me with the code

  • 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-07T00:49:13+00:00Added an answer on June 7, 2026 at 12:49 am

    In the $post_string that you read from your uploaded file, does that file end with a <commit />? Without that nothing will get committed to Solr so make sure your set of commands ends with <commit />.

    Also, I would highly not recommend this way of updating files. If someone unscrupulous figures out your pipeline and how to run this file, they can easily wreak havoc with your Solr index.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am indexing a pdf file using this php script. The curl give me
I'm using a PHP library called solr-php-client (http://code.google.com/p/solr-php-client/) to interface with my Solr server.
Is it possible for hackers ( or other ) to upload/write a php file
I'm using Python's gensim library to do latent semantic indexing. I followed the tutorials
I need xml file for indexing my website for google crawling. I'm using some
I think of implementing a file search program using indexing in linux... I know
Indexing Service is set up on our file server to index a couple dozen
Indexing, code completion, & coloring disappear from my projects on a fairly regular basis,
I am indexing some URIs in SOLR using the UAX29URLEmailTokenizerFactory tokenizer. The problem is
Using a very large raw binary data file, I will be creating a large

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.