PHP - i have problem with download high files












0
















i Got the problem, my problem with high files. for example i have a 20mb file, its run without problem. them i give it 50mb file. its not load.....




this is my code:



$file = './' . $elements[ $oindex ] . DIRECTORY_SEPARATOR . $elements[ $otype ] . DIRECTORY_SEPARATOR . $elements[ $odate ] . DIRECTORY_SEPARATOR . urldecode( $elements[ $ofile ] );


after this i send data fo output function.
the output code:



$file = fopen( $filename, 'r' );

$mimetype = mime_content_type( $file );
header( 'Content-Type: ' . $mimetype );

echo fpassthru( $file );
fclose( $file );


its work for all formats
but when i use url like this:



http://localhost/onwebsite_ir/c/files/ow_free/2018-11/y2mate.com%20-%20retrain_your_mind_new_motivational_video_very_powerful_xp2qjshr-r4_1080p.mp4


its not work....



then use this urls :



http://localhost/onwebsite_ir/c/files/ow_free/2018-11/NO%20EXCUSES%20-%20Best%20Motivational%20Video.mp4

http://localhost/onwebsite_ir/c/files/ow_portable_ocourses_on/2018-11/01%20-%20Introduction%20to%20the%20Tools%20used%20in%20Mobile%20Repairing%20(English).jpg


it will work without any problem



i test any wayse but it not work...



there is problem with video files...



please help me....



Its Downloader Plugin (Check Access Users To Download Files) On Wordpress





after this i update my code to:



$file_size = filesize( $filename );
$file = @fopen( $filename, "rb" );
if ( $file ) {
header( "Content-Disposition: attachment; filename="$fn"" );
header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
header( "Content-Length: $file_size" );
$mimetype = mime_content_type( $file );
header( 'Content-Type: ' . $mimetype );
set_time_limit( 0 );
if ( $t == 'ow_free' ) {
echo fpassthru( $file );

}
fclose( $file );
}


after some tests i got underestand my problem with high files then i used this code for download:



$file_size = filesize( $filename );
$file = @fopen( $filename, "rb" );
if ( $file ) {
header( "Content-Disposition: attachment; filename="$fn"" );
header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
header( "Content-Length: $file_size" );
$mimetype = mime_content_type( $file );
header( 'Content-Type: ' . $mimetype );
set_time_limit( 0 );
fseek( $file, 0 );
while ( ! feof( $file ) ) {
print( @fread( $file, 1024 * 8 ) );
ob_flush();
flush();
if ( connection_status() != 0 ) {
@fclose( $file );
exit;
}
}


its works...
but when i played video by this way or downloading, my website goes down...
is the other ways?










share|improve this question




















  • 1





    Re: "but it not work...", Is there an error in the log? please be more specific.

    – l'L'l
    Nov 25 '18 at 4:21






  • 1





    Please add more information on "not work".

    – Geno Chen
    Nov 25 '18 at 4:22











  • Use var_dump to see what is in $elements and the URL that is being constructed

    – user2182349
    Nov 25 '18 at 4:23











  • Please edit your question to include the info text; pictures are not so helpful.

    – miken32
    Nov 25 '18 at 4:52











  • echo file_get_contents($filename); not work for this.....

    – mostafabaghi
    Nov 25 '18 at 20:20
















0
















i Got the problem, my problem with high files. for example i have a 20mb file, its run without problem. them i give it 50mb file. its not load.....




this is my code:



$file = './' . $elements[ $oindex ] . DIRECTORY_SEPARATOR . $elements[ $otype ] . DIRECTORY_SEPARATOR . $elements[ $odate ] . DIRECTORY_SEPARATOR . urldecode( $elements[ $ofile ] );


after this i send data fo output function.
the output code:



$file = fopen( $filename, 'r' );

$mimetype = mime_content_type( $file );
header( 'Content-Type: ' . $mimetype );

echo fpassthru( $file );
fclose( $file );


its work for all formats
but when i use url like this:



http://localhost/onwebsite_ir/c/files/ow_free/2018-11/y2mate.com%20-%20retrain_your_mind_new_motivational_video_very_powerful_xp2qjshr-r4_1080p.mp4


its not work....



then use this urls :



http://localhost/onwebsite_ir/c/files/ow_free/2018-11/NO%20EXCUSES%20-%20Best%20Motivational%20Video.mp4

http://localhost/onwebsite_ir/c/files/ow_portable_ocourses_on/2018-11/01%20-%20Introduction%20to%20the%20Tools%20used%20in%20Mobile%20Repairing%20(English).jpg


it will work without any problem



i test any wayse but it not work...



there is problem with video files...



please help me....



Its Downloader Plugin (Check Access Users To Download Files) On Wordpress





after this i update my code to:



$file_size = filesize( $filename );
$file = @fopen( $filename, "rb" );
if ( $file ) {
header( "Content-Disposition: attachment; filename="$fn"" );
header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
header( "Content-Length: $file_size" );
$mimetype = mime_content_type( $file );
header( 'Content-Type: ' . $mimetype );
set_time_limit( 0 );
if ( $t == 'ow_free' ) {
echo fpassthru( $file );

}
fclose( $file );
}


after some tests i got underestand my problem with high files then i used this code for download:



$file_size = filesize( $filename );
$file = @fopen( $filename, "rb" );
if ( $file ) {
header( "Content-Disposition: attachment; filename="$fn"" );
header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
header( "Content-Length: $file_size" );
$mimetype = mime_content_type( $file );
header( 'Content-Type: ' . $mimetype );
set_time_limit( 0 );
fseek( $file, 0 );
while ( ! feof( $file ) ) {
print( @fread( $file, 1024 * 8 ) );
ob_flush();
flush();
if ( connection_status() != 0 ) {
@fclose( $file );
exit;
}
}


its works...
but when i played video by this way or downloading, my website goes down...
is the other ways?










share|improve this question




















  • 1





    Re: "but it not work...", Is there an error in the log? please be more specific.

    – l'L'l
    Nov 25 '18 at 4:21






  • 1





    Please add more information on "not work".

    – Geno Chen
    Nov 25 '18 at 4:22











  • Use var_dump to see what is in $elements and the URL that is being constructed

    – user2182349
    Nov 25 '18 at 4:23











  • Please edit your question to include the info text; pictures are not so helpful.

    – miken32
    Nov 25 '18 at 4:52











  • echo file_get_contents($filename); not work for this.....

    – mostafabaghi
    Nov 25 '18 at 20:20














0












0








0









i Got the problem, my problem with high files. for example i have a 20mb file, its run without problem. them i give it 50mb file. its not load.....




this is my code:



$file = './' . $elements[ $oindex ] . DIRECTORY_SEPARATOR . $elements[ $otype ] . DIRECTORY_SEPARATOR . $elements[ $odate ] . DIRECTORY_SEPARATOR . urldecode( $elements[ $ofile ] );


after this i send data fo output function.
the output code:



$file = fopen( $filename, 'r' );

$mimetype = mime_content_type( $file );
header( 'Content-Type: ' . $mimetype );

echo fpassthru( $file );
fclose( $file );


its work for all formats
but when i use url like this:



http://localhost/onwebsite_ir/c/files/ow_free/2018-11/y2mate.com%20-%20retrain_your_mind_new_motivational_video_very_powerful_xp2qjshr-r4_1080p.mp4


its not work....



then use this urls :



http://localhost/onwebsite_ir/c/files/ow_free/2018-11/NO%20EXCUSES%20-%20Best%20Motivational%20Video.mp4

http://localhost/onwebsite_ir/c/files/ow_portable_ocourses_on/2018-11/01%20-%20Introduction%20to%20the%20Tools%20used%20in%20Mobile%20Repairing%20(English).jpg


it will work without any problem



i test any wayse but it not work...



there is problem with video files...



please help me....



Its Downloader Plugin (Check Access Users To Download Files) On Wordpress





after this i update my code to:



$file_size = filesize( $filename );
$file = @fopen( $filename, "rb" );
if ( $file ) {
header( "Content-Disposition: attachment; filename="$fn"" );
header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
header( "Content-Length: $file_size" );
$mimetype = mime_content_type( $file );
header( 'Content-Type: ' . $mimetype );
set_time_limit( 0 );
if ( $t == 'ow_free' ) {
echo fpassthru( $file );

}
fclose( $file );
}


after some tests i got underestand my problem with high files then i used this code for download:



$file_size = filesize( $filename );
$file = @fopen( $filename, "rb" );
if ( $file ) {
header( "Content-Disposition: attachment; filename="$fn"" );
header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
header( "Content-Length: $file_size" );
$mimetype = mime_content_type( $file );
header( 'Content-Type: ' . $mimetype );
set_time_limit( 0 );
fseek( $file, 0 );
while ( ! feof( $file ) ) {
print( @fread( $file, 1024 * 8 ) );
ob_flush();
flush();
if ( connection_status() != 0 ) {
@fclose( $file );
exit;
}
}


its works...
but when i played video by this way or downloading, my website goes down...
is the other ways?










share|improve this question

















i Got the problem, my problem with high files. for example i have a 20mb file, its run without problem. them i give it 50mb file. its not load.....




this is my code:



$file = './' . $elements[ $oindex ] . DIRECTORY_SEPARATOR . $elements[ $otype ] . DIRECTORY_SEPARATOR . $elements[ $odate ] . DIRECTORY_SEPARATOR . urldecode( $elements[ $ofile ] );


after this i send data fo output function.
the output code:



$file = fopen( $filename, 'r' );

$mimetype = mime_content_type( $file );
header( 'Content-Type: ' . $mimetype );

echo fpassthru( $file );
fclose( $file );


its work for all formats
but when i use url like this:



http://localhost/onwebsite_ir/c/files/ow_free/2018-11/y2mate.com%20-%20retrain_your_mind_new_motivational_video_very_powerful_xp2qjshr-r4_1080p.mp4


its not work....



then use this urls :



http://localhost/onwebsite_ir/c/files/ow_free/2018-11/NO%20EXCUSES%20-%20Best%20Motivational%20Video.mp4

http://localhost/onwebsite_ir/c/files/ow_portable_ocourses_on/2018-11/01%20-%20Introduction%20to%20the%20Tools%20used%20in%20Mobile%20Repairing%20(English).jpg


it will work without any problem



i test any wayse but it not work...



there is problem with video files...



please help me....



Its Downloader Plugin (Check Access Users To Download Files) On Wordpress





after this i update my code to:



$file_size = filesize( $filename );
$file = @fopen( $filename, "rb" );
if ( $file ) {
header( "Content-Disposition: attachment; filename="$fn"" );
header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
header( "Content-Length: $file_size" );
$mimetype = mime_content_type( $file );
header( 'Content-Type: ' . $mimetype );
set_time_limit( 0 );
if ( $t == 'ow_free' ) {
echo fpassthru( $file );

}
fclose( $file );
}


after some tests i got underestand my problem with high files then i used this code for download:



$file_size = filesize( $filename );
$file = @fopen( $filename, "rb" );
if ( $file ) {
header( "Content-Disposition: attachment; filename="$fn"" );
header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
header( "Content-Length: $file_size" );
$mimetype = mime_content_type( $file );
header( 'Content-Type: ' . $mimetype );
set_time_limit( 0 );
fseek( $file, 0 );
while ( ! feof( $file ) ) {
print( @fread( $file, 1024 * 8 ) );
ob_flush();
flush();
if ( connection_status() != 0 ) {
@fclose( $file );
exit;
}
}


its works...
but when i played video by this way or downloading, my website goes down...
is the other ways?







php fopen urldecode






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 25 '18 at 19:55







mostafabaghi

















asked Nov 25 '18 at 4:15









mostafabaghimostafabaghi

37




37








  • 1





    Re: "but it not work...", Is there an error in the log? please be more specific.

    – l'L'l
    Nov 25 '18 at 4:21






  • 1





    Please add more information on "not work".

    – Geno Chen
    Nov 25 '18 at 4:22











  • Use var_dump to see what is in $elements and the URL that is being constructed

    – user2182349
    Nov 25 '18 at 4:23











  • Please edit your question to include the info text; pictures are not so helpful.

    – miken32
    Nov 25 '18 at 4:52











  • echo file_get_contents($filename); not work for this.....

    – mostafabaghi
    Nov 25 '18 at 20:20














  • 1





    Re: "but it not work...", Is there an error in the log? please be more specific.

    – l'L'l
    Nov 25 '18 at 4:21






  • 1





    Please add more information on "not work".

    – Geno Chen
    Nov 25 '18 at 4:22











  • Use var_dump to see what is in $elements and the URL that is being constructed

    – user2182349
    Nov 25 '18 at 4:23











  • Please edit your question to include the info text; pictures are not so helpful.

    – miken32
    Nov 25 '18 at 4:52











  • echo file_get_contents($filename); not work for this.....

    – mostafabaghi
    Nov 25 '18 at 20:20








1




1





Re: "but it not work...", Is there an error in the log? please be more specific.

– l'L'l
Nov 25 '18 at 4:21





Re: "but it not work...", Is there an error in the log? please be more specific.

– l'L'l
Nov 25 '18 at 4:21




1




1





Please add more information on "not work".

– Geno Chen
Nov 25 '18 at 4:22





Please add more information on "not work".

– Geno Chen
Nov 25 '18 at 4:22













Use var_dump to see what is in $elements and the URL that is being constructed

– user2182349
Nov 25 '18 at 4:23





Use var_dump to see what is in $elements and the URL that is being constructed

– user2182349
Nov 25 '18 at 4:23













Please edit your question to include the info text; pictures are not so helpful.

– miken32
Nov 25 '18 at 4:52





Please edit your question to include the info text; pictures are not so helpful.

– miken32
Nov 25 '18 at 4:52













echo file_get_contents($filename); not work for this.....

– mostafabaghi
Nov 25 '18 at 20:20





echo file_get_contents($filename); not work for this.....

– mostafabaghi
Nov 25 '18 at 20:20












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53464611%2fphp-i-have-problem-with-download-high-files%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53464611%2fphp-i-have-problem-with-download-high-files%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Feedback on college project

Futebolista

Albești (Vaslui)