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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:28:52+00:00 2026-06-08T02:28:52+00:00

I have my users uploading a text file which then gets processed by my

  • 0

I have my users uploading a text file which then gets processed by my application. Once the processing is done, I would like to save a copy of this text file somewhere on my server for future reference. Currently, the uploaded text file stays in the PHP temp folder until it is closed by my app.

What’s a simple way to accomplish this?

BTW, I’ll need to know how to do this on my web server along with localhost (for testing).

  • 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-08T02:28:54+00:00Added an answer on June 8, 2026 at 2:28 am

    You can use the fwrite function (this is probably not a very good idea in this particular example though.

    $fp = fopen('data.txt', 'w');
    fwrite($fp, $yourContents);
    fclose($fp);
    

    But, if you already have the file simply copy it using the copy command (if you want to keep it in the temp folder that is, if not move it with the rename function instead).

    To copy, do something like this

    $tempfile = 'tempfile.txt';
    $newfile = 'newfile.txt';
    
    if (copy($tempfile, $newfile)) {
        echo "success!";
    } else {
        echo "misery :(";
    }
    

    To move with rename

    // Rename returns a bool, just as in the copy example
    rename("/tmp/tempfile.txt", "/home/user/files/newfile.txt");
    

    Added this: To move with move_uploaded_file

    Please note, I didn’t test this in a development environment. This may not execute perfectly.

    $uploads_dir = 'C:\\movefiles\\here\\';
    foreach ($_FILES["upload-tracking-file"]["error"] as $key => $error) {
        if ($error == UPLOAD_ERR_OK) {
            $tmp_name = $_FILES["upload-tracking-file"]["tmp_name"][$key];
            $name = $_FILES["upload-tracking-file"]["name"][$key];
            move_uploaded_file($tmp_name, "$uploads_dir\\$name");
        }
    }
    

    References

    • Copy, http://php.net/manual/en/function.copy.php
    • Move (rename), http://php.net/manual/en/function.rename.php
    • move_uploaded_file, http://php.net/manual/en/function.move-uploaded-file.php
    • fwrite, http://php.net/manual/en/function.fwrite.php
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem I have a file which contains such text (nothing else) 2010-10-05 I would
In my application I have Users, Organisations and Employees. There are domain objects for
In my web application I will have users, each user will have albums, and
Imagine this simple form for uploading a file: <form action=upload enctype=multipart/form-data> <input type=text name=name/>
I am making an application that allows users to upload a file in a
I have a website up and running which makes use of file uploads. Everything
My Ruby on Rails application uses S3 and Paperclip. I have users upload a
On the site I am developing, I have a file input that users can
I have a form where a user selects a file, and then should be
I have a filemanager application that allows users to upload files to the server

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.