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

  • Home
  • SEARCH
  • 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 1000697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:33:18+00:00 2026-05-16T07:33:18+00:00

I want to copy all the video files on my server & save it

  • 0

I want to copy all the video files on my server & save it in the web contents folder of a web service , so that it can be visible to all later on !

How should i proceeed ?

  • 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-16T07:33:19+00:00Added an answer on May 16, 2026 at 7:33 am

    Basically you need two sides. The first one is on Android. You have to send (Do it in an ASyncTask e.x.) the data to your webservice. Here I made a little method for you, which sends a file and some additional POST values to an URL:

    private boolean handleFile(String filePath, String mimeType) {      
        HttpURLConnection connection = null;
        DataOutputStream outStream = null;
        DataInputStream inStream = null;
    
        String lineEnd = "\r\n";
        String twoHyphens = "--";
        String boundary = "*****";
    
        int bytesRead, bytesAvailable, bufferSize;
    
        byte[] buffer;
    
        int maxBufferSize = 1*1024*1024;
    
        String urlString = "http://your.domain.com/webservice.php";
    
        try {
            FileInputStream fileInputStream = null;
            try {
                fileInputStream = new FileInputStream(new File(filePath));
            } catch(FileNotFoundException e) { }
            URL url = new URL(urlString);
            connection = (HttpURLConnection) url.openConnection();
            connection.setDoInput(true);
            connection.setDoOutput(true);
            connection.setUseCaches(false);
    
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Connection", "Keep-Alive");
            connection.setRequestProperty("Content-Type", "multipart/form-data;boundary="+boundary);            
    
            outStream = new DataOutputStream(connection.getOutputStream());
    
            // Some POST values
            outStream.writeBytes(addParam("additional_param", "some value");
          outStream.writeBytes(addParam("additional_param 2", "some other value");              
    
            // The file with the name "uploadedfile"
            outStream.writeBytes(twoHyphens + boundary + lineEnd);
            outStream.writeBytes("Content-Disposition: form-data; name=\"uploadedfile\";filename=\"" + filePath +"\"" + lineEnd + "Content-Type: " + mimeType + lineEnd + "Content-Transfer-Encoding: binary" + lineEnd);           
            outStream.writeBytes(lineEnd);
    
            bytesAvailable = fileInputStream.available();
            bufferSize = Math.min(bytesAvailable, maxBufferSize);
            buffer = new byte[bufferSize];
    
            bytesRead = fileInputStream.read(buffer, 0, bufferSize);
    
              while (bytesRead > 0) {
                  outStream.write(buffer, 0, bufferSize);
                bytesAvailable = fileInputStream.available();
                bufferSize = Math.min(bytesAvailable, maxBufferSize);
                bytesRead = fileInputStream.read(buffer, 0, bufferSize);
            }
    
            outStream.writeBytes(lineEnd);
            outStream.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);
    
            fileInputStream.close();
            outStream.flush();
            outStream.close();  
        } catch (MalformedURLException e) {
            Log.e("APP", "MalformedURLException while sending\n" + e.getMessage());
        } catch (IOException e) {
            Log.e("APP", "IOException while sending\n" + e.getMessage());
        }
    
    
        // This part checks the response of the server. If its "UPLOAD OK" the method returns true
        try {
           inStream = new DataInputStream( connection.getInputStream() );
           String str;
    
           while (( str = inStream.readLine()) != null) {
               if(str=="UPLOAD OK") {
                   return true;
               } else {
                   return false;
               }
           }
           inStream.close();
        } catch (IOException e){
            Log.e("APP", "IOException while sending\n" + e.getMessage());
        }
        return false;
    }
    

    Now, we have got the other side: http://your.domain.com/webservice.php
    Your server. It needs some logic, for example in PHP, to handle the sent POST request.
    Something like this would work:

    <?php
       $target_path = "videos/";      
    
       $target_path = $target_path.'somename.3gp';
       if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
           exit("UPLOAD OK");
       } else {
           exit("UPLOAD NOT OK");
       }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to copy all files that begin with a string to a folder
I want to copy all the ca certificates of firefox to my a folder
I want to copy all my database to remote database server. I have access
I want to copy all the files, and copy all the folders, included empty
I want to copy all my JPG files in one directory to a new
I have a directory with several subdirectories with files. How can I copy all
i want to copy all files and folders from one drive to another drive
I want to copy all the *.jar files to another directory i wrote the
I have a local SQL Server Express database that I want to copy to
I want to copy a record with all his relations. I'm trying with: $o

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.