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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:59:05+00:00 2026-05-24T15:59:05+00:00

I have two servers. I want delete file from second server via first server!

  • 0

I have two servers. I want delete file from second server via first server!

For example:

  • first-server.com
  • second-server.com

I have made two php files – file on first server and file on second server.

The file on first server contains

files.php

while($file = mysql_fetch_array($files){
echo $file['file_name'];
echo '<a href="second_server.com/delete.php?file=' . $file['file_name'] . '">Delete</a>';
}

the file on second server contains

delete.php

if($_GET['file']){
if(file_exists($_GET['file']){
unlink($_GET['file'];
//file deleted !
}

No it’s ok , but. I want done this job without redirect me or visitor to the second server

For example : ajax or curl or something like that. What is the best way to do that?


Edit.

The codes above is just tests. It’s not my real files. Please help in the way to process delete request without redirect to second server php file.

  • 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-05-24T15:59:07+00:00Added an answer on May 24, 2026 at 3:59 pm

    I think a simple file_get_contents is enough:

    File on first server:

    $result = file_get_contents('second-sercer.com/delete.php?file=text.txt&some_security_token=asd');
    //From $result you will know what was the result on the other server
    

    File on second server (delete.php);

    if($_GET['some_security_token'] == "asd"){
      if(file_exists($_GET['file']){
        if(unlink($_GET['file'])){
           //File deleted we are cool
           echo 1;
        } else {
           //File deletion failed
           echo 0;
        }
      }else{
        //File don't exists
        echo -1;
      }
    }else{
     //bad token
     echo -2;
    }
    

    So this way your first server on script level goes to the second server so you can check parameters before that. And the second server sends back error / success codes so you can handle them on first server:

    1  - success
    0  - failed deletion
    -1 - file doesn't even exists
    -2 - bad security token
    

    I do not include a way to create a token that both of the servers know. You can hash the file name with some key value for start, but you have to make it expensive to guess. I just try to point out that you need this kind of security too to make it even safer. And you have to find out a way to protect file system from deleting files that important for second-server. For example you only let the deletion of files in some folder only.

    You could use cURl too the same way for this. But always try to return info for the first-server.com about the process on the second-server.com

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

Sidebar

Related Questions

I have two servers, the first one with SQL Server 2005 and the second
I have two servers. Server A and server B. I use php, jquery for
I have two servers where I installed SQL Server 2008 Production: RAID 1 on
You have two servers when you perform a SQL Server database mirroring You have
I have two grails servers: Server - has read/write access to the database Web
On a non-production machine, I have two instances of SQL Server 2005. I want
I have two DB servers, i.e Server1 and Server2. I want to transfer data
Here's the situation... I have two servers, server 1 and server 2. server 1
I have two servers with virtually identical setups (the second that is working has
I have two servers - one Django, the other likely to be written in

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.