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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:51:21+00:00 2026-06-07T03:51:21+00:00

I try to send video files (.mp4) to a server. I know that sending

  • 0

I try to send video files (.mp4) to a server. I know that sending byte arrays is a pretty outdated method, but the problem is that I cant change the server, not allowed to.

When sending files smaller than 1 mb, everything is fine, but with larger files it doesnt work. does anyone know how to solve that?? Is it possible at all?

Server code: (in $data is the actual byte array, the 128 characters in front are just for file management, like file name and id)

 <?php

//get data
if (!isset($HTTP_RAW_POST_DATA))
$HTTP_RAW_POST_DATA = file_get_contents("php://input");

//cass -------------------------------------------------------------
$filename = substr($HTTP_RAW_POST_DATA, 0, 128);    
$filename = trim($filename, " ");               
$filename = explode(";",$filename);     
$fname = $filename[0];
$q_id = $filename[1];
$data = substr($HTTP_RAW_POST_DATA, 128);

$length = strlen($data);

$file = fopen("cassDebug.txt","w");
$textout = "QID: $q_id NAME: $fname LENGTH: $length";

fwrite($file,$textout);
fclose($file);

// write file
if(strlen($data)>0){
        $FSize = strlen($data);
        $f = fopen("media/$fname",'w');
        fwrite($f,$data,$FSize);
         fclose($f);
 }

?> 

Java code:

try
    {
    FileInputStream fileInputStream = new FileInputStream(new File(pathToOurFile) );

    URL url = new URL(urlServer);
    connection = (HttpURLConnection) url.openConnection();

    // Allow Inputs & Outputs
    connection.setDoInput(true);
    connection.setDoOutput(true);
    connection.setUseCaches(false);

    connection.setRequestMethod("POST");
    connection.setRequestProperty("Content-Type", "application/octet-stream");

    connection.connect();

    OutputStream os = connection.getOutputStream();

    String fileName = makeLength(fname, fname.length());
    String comma = ";";
    String audioQuestionId = makeLength(QID, 128 - fname.length() - comma.length());

    os.write(fileName.getBytes());
    os.write(comma.getBytes());
    os.write(audioQuestionId.getBytes());

    // Initialize byte array for data transfer
    byte[] dataBuffer = new byte[2*1024];

    // Get total bytes in the file
            long totalBytes = fileInputStream.available();

            System.out.println("Total bytes: "+totalBytes);

            long bytesRead = 0; 
        int n = 0;
        while ((n = fileInputStream.read(dataBuffer, 0, 2*1024)) != -1) {
              os.write(dataBuffer, 0, n);
              bytesRead += n;
        }

            System.out.println(connection.getResponseCode());
    System.out.println(connection.getResponseMessage());

    fileInputStream.close();
    os.flush();
    os.close();
    connection.disconnect();
    }
    catch (Exception ex){
        System.out.println(ex);
    }
}
  • 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-07T03:51:21+00:00Added an answer on June 7, 2026 at 3:51 am

    Check your php.ini file. The default POST limit is 1MB. You probably didn’t raise it.

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

Sidebar

Related Questions

I try to send a request to my server via GET, but qooxdoo sends
I try to send an email, but I have a problem, however, I found
i try to send some data to my php file from ajax , but
i try to send data to my php scripts but i think i miss
i try to send my datas to php with ajax but there's strange mistake.
I try to send a sms using next code, but recipient gets my message
I try to send some values using ASIFormDataRequest. The problem is that even though
I try to send integer by msg queue but the function mq_send(mq, &val ,
When I try to create pipeline that uses H264 to transmit video, I get
I want to send a video file from a server written in java to

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.