Download files from the download server with the help of php and mvcCreate a CSV File for a user in PHPDeleting an element from an array in PHPConvert HTML + CSS to PDF with PHP?Having Django serve downloadable filesDownload a file with Android, and showing the progress in a ProgressDialogReference — What does this symbol mean in PHP?Download a file by jQuery.AjaxReturning a file to View/Download in ASP.NET MVCDude, where's my php.ini? (server config)Do I need Content-Type: application/octet-stream for file download?
What is the minimum required technology to reanimate someone who has been cryogenically frozen?
Is there an application which does HTTP PUT?
How to avoid making self and former employee look bad when reporting on fixing former employee's work?
How long can fsck take on a 30 TB volume?
How to handle DM constantly stealing everything from sleeping characters?
What's an appropriate age to involve kids in life changing decisions?
Company stopped paying my salary. What are my options?
What replaces x86 intrinsics for C when Apple ditches Intel CPUs for their own chips?
Why do the Avengers care about returning these items in Endgame?
I might have messed up in the 'Future Work' section of my thesis
What's the "magic similar to the Knock spell" referenced in the Dungeon of the Mad Mage adventure?
Does Thread.yield() do anything if we have enough processors to service all threads?
Gift for mentor after his thesis defense?
What does the "DS" in "DS-..." US visa application forms stand for?
Is it safe to keep the GPU on 100% utilization for a very long time?
TeX Gyre Pagella Math Integral sign much too small
Why use steam instead of just hot air?
Is there any evidence to support the claim that the United States was "suckered into WW1" by Zionists, made by Benjamin Freedman in his 1961 speech
Can I bring back Planetary Romance as a genre?
Program for finding longest run of zeros from a list of 100 random integers which are either 0 or 1
Not taking the bishop by the knight, why?
How did Captain Marvel know where to find these characters?
how to find out if there's files in a folder and exit accordingly (in KSH)
Are double contractions formal? Eg: "couldn't've" for "could not have"
Download files from the download server with the help of php and mvc
Create a CSV File for a user in PHPDeleting an element from an array in PHPConvert HTML + CSS to PDF with PHP?Having Django serve downloadable filesDownload a file with Android, and showing the progress in a ProgressDialogReference — What does this symbol mean in PHP?Download a file by jQuery.AjaxReturning a file to View/Download in ASP.NET MVCDude, where's my php.ini? (server config)Do I need Content-Type: application/octet-stream for file download?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have a download server for files.
And I want my users to get the files from the download server.
My download server is Linux.
I want when the user clicks on the download button.
Get the file directly from the download server.
I do not want to use the stream to download ...
I want to connect to the download server via the link and then download it using PHP
My site is with mvc
Thank you, step by step to help me
php asp.net-mvc wcf download
add a comment |
I have a download server for files.
And I want my users to get the files from the download server.
My download server is Linux.
I want when the user clicks on the download button.
Get the file directly from the download server.
I do not want to use the stream to download ...
I want to connect to the download server via the link and then download it using PHP
My site is with mvc
Thank you, step by step to help me
php asp.net-mvc wcf download
1
Could you please provide code you have so far? And what did you try to accomplish your task?
– Alexander
Mar 24 at 11:41
@Alexander Actually He posted his code as a new answer
– osman Rahimi
May 5 at 10:08
add a comment |
I have a download server for files.
And I want my users to get the files from the download server.
My download server is Linux.
I want when the user clicks on the download button.
Get the file directly from the download server.
I do not want to use the stream to download ...
I want to connect to the download server via the link and then download it using PHP
My site is with mvc
Thank you, step by step to help me
php asp.net-mvc wcf download
I have a download server for files.
And I want my users to get the files from the download server.
My download server is Linux.
I want when the user clicks on the download button.
Get the file directly from the download server.
I do not want to use the stream to download ...
I want to connect to the download server via the link and then download it using PHP
My site is with mvc
Thank you, step by step to help me
php asp.net-mvc wcf download
php asp.net-mvc wcf download
asked Mar 23 at 8:44
40454045
1
1
1
Could you please provide code you have so far? And what did you try to accomplish your task?
– Alexander
Mar 24 at 11:41
@Alexander Actually He posted his code as a new answer
– osman Rahimi
May 5 at 10:08
add a comment |
1
Could you please provide code you have so far? And what did you try to accomplish your task?
– Alexander
Mar 24 at 11:41
@Alexander Actually He posted his code as a new answer
– osman Rahimi
May 5 at 10:08
1
1
Could you please provide code you have so far? And what did you try to accomplish your task?
– Alexander
Mar 24 at 11:41
Could you please provide code you have so far? And what did you try to accomplish your task?
– Alexander
Mar 24 at 11:41
@Alexander Actually He posted his code as a new answer
– osman Rahimi
May 5 at 10:08
@Alexander Actually He posted his code as a new answer
– osman Rahimi
May 5 at 10:08
add a comment |
1 Answer
1
active
oldest
votes
thank you
Stream stream = null;
//This controls how many bytes to read at a time and send to the client
int bytesToRead = 10000;
// Buffer to read bytes in chunk size specified above
byte[] buffer = new Byte[bytesToRead];
// The number of bytes read
try
//Create a WebRequest to get the file
HttpWebRequest fileReq = (HttpWebRequest)HttpWebRequest.Create(Global.UrlVideoPrice + IdCourse + "//" + IdTopic+".rar");
//Create a response for this request
HttpWebResponse fileResp = (HttpWebResponse)fileReq.GetResponse();
if (fileReq.ContentLength > 0)
fileResp.ContentLength = fileReq.ContentLength;
//Get the Stream returned from the response
stream = fileResp.GetResponseStream();
// prepare the response to the client. resp is the client Response
var resp = System.Web.HttpContext.Current.Response;
//Indicate the type of data being sent
resp.ContentType = "application/octet-stream";
//Name the file
resp.AddHeader("Content-Disposition", "attachment; filename="" + Topic.fldName + ".rar"");
resp.AddHeader("Content-Length", fileResp.ContentLength.ToString());
int length;
do
// Verify that the client is connected.
if (resp.IsClientConnected)
// Read data into the buffer.
length = stream.Read(buffer, 0, bytesToRead);
// and write it out to the response's output stream
resp.OutputStream.Write(buffer, 0, length);
// Flush the data
resp.Flush();
//Clear the buffer
buffer = new Byte[bytesToRead];
else
// cancel the download if client has disconnected
length = -1;
while (length > 0); //Repeat until no data is read
finally
if (stream != null)
//Close the input stream
stream.Close();
This is my download code.
Now I want the user to get the files directly from the download server.
Do not use site traffic to download the file.
And use server download traffic
you can edit the question to add code
– 1SaeedSalehi
Apr 7 at 18:55
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55312071%2fdownload-files-from-the-download-server-with-the-help-of-php-and-mvc%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
thank you
Stream stream = null;
//This controls how many bytes to read at a time and send to the client
int bytesToRead = 10000;
// Buffer to read bytes in chunk size specified above
byte[] buffer = new Byte[bytesToRead];
// The number of bytes read
try
//Create a WebRequest to get the file
HttpWebRequest fileReq = (HttpWebRequest)HttpWebRequest.Create(Global.UrlVideoPrice + IdCourse + "//" + IdTopic+".rar");
//Create a response for this request
HttpWebResponse fileResp = (HttpWebResponse)fileReq.GetResponse();
if (fileReq.ContentLength > 0)
fileResp.ContentLength = fileReq.ContentLength;
//Get the Stream returned from the response
stream = fileResp.GetResponseStream();
// prepare the response to the client. resp is the client Response
var resp = System.Web.HttpContext.Current.Response;
//Indicate the type of data being sent
resp.ContentType = "application/octet-stream";
//Name the file
resp.AddHeader("Content-Disposition", "attachment; filename="" + Topic.fldName + ".rar"");
resp.AddHeader("Content-Length", fileResp.ContentLength.ToString());
int length;
do
// Verify that the client is connected.
if (resp.IsClientConnected)
// Read data into the buffer.
length = stream.Read(buffer, 0, bytesToRead);
// and write it out to the response's output stream
resp.OutputStream.Write(buffer, 0, length);
// Flush the data
resp.Flush();
//Clear the buffer
buffer = new Byte[bytesToRead];
else
// cancel the download if client has disconnected
length = -1;
while (length > 0); //Repeat until no data is read
finally
if (stream != null)
//Close the input stream
stream.Close();
This is my download code.
Now I want the user to get the files directly from the download server.
Do not use site traffic to download the file.
And use server download traffic
you can edit the question to add code
– 1SaeedSalehi
Apr 7 at 18:55
add a comment |
thank you
Stream stream = null;
//This controls how many bytes to read at a time and send to the client
int bytesToRead = 10000;
// Buffer to read bytes in chunk size specified above
byte[] buffer = new Byte[bytesToRead];
// The number of bytes read
try
//Create a WebRequest to get the file
HttpWebRequest fileReq = (HttpWebRequest)HttpWebRequest.Create(Global.UrlVideoPrice + IdCourse + "//" + IdTopic+".rar");
//Create a response for this request
HttpWebResponse fileResp = (HttpWebResponse)fileReq.GetResponse();
if (fileReq.ContentLength > 0)
fileResp.ContentLength = fileReq.ContentLength;
//Get the Stream returned from the response
stream = fileResp.GetResponseStream();
// prepare the response to the client. resp is the client Response
var resp = System.Web.HttpContext.Current.Response;
//Indicate the type of data being sent
resp.ContentType = "application/octet-stream";
//Name the file
resp.AddHeader("Content-Disposition", "attachment; filename="" + Topic.fldName + ".rar"");
resp.AddHeader("Content-Length", fileResp.ContentLength.ToString());
int length;
do
// Verify that the client is connected.
if (resp.IsClientConnected)
// Read data into the buffer.
length = stream.Read(buffer, 0, bytesToRead);
// and write it out to the response's output stream
resp.OutputStream.Write(buffer, 0, length);
// Flush the data
resp.Flush();
//Clear the buffer
buffer = new Byte[bytesToRead];
else
// cancel the download if client has disconnected
length = -1;
while (length > 0); //Repeat until no data is read
finally
if (stream != null)
//Close the input stream
stream.Close();
This is my download code.
Now I want the user to get the files directly from the download server.
Do not use site traffic to download the file.
And use server download traffic
you can edit the question to add code
– 1SaeedSalehi
Apr 7 at 18:55
add a comment |
thank you
Stream stream = null;
//This controls how many bytes to read at a time and send to the client
int bytesToRead = 10000;
// Buffer to read bytes in chunk size specified above
byte[] buffer = new Byte[bytesToRead];
// The number of bytes read
try
//Create a WebRequest to get the file
HttpWebRequest fileReq = (HttpWebRequest)HttpWebRequest.Create(Global.UrlVideoPrice + IdCourse + "//" + IdTopic+".rar");
//Create a response for this request
HttpWebResponse fileResp = (HttpWebResponse)fileReq.GetResponse();
if (fileReq.ContentLength > 0)
fileResp.ContentLength = fileReq.ContentLength;
//Get the Stream returned from the response
stream = fileResp.GetResponseStream();
// prepare the response to the client. resp is the client Response
var resp = System.Web.HttpContext.Current.Response;
//Indicate the type of data being sent
resp.ContentType = "application/octet-stream";
//Name the file
resp.AddHeader("Content-Disposition", "attachment; filename="" + Topic.fldName + ".rar"");
resp.AddHeader("Content-Length", fileResp.ContentLength.ToString());
int length;
do
// Verify that the client is connected.
if (resp.IsClientConnected)
// Read data into the buffer.
length = stream.Read(buffer, 0, bytesToRead);
// and write it out to the response's output stream
resp.OutputStream.Write(buffer, 0, length);
// Flush the data
resp.Flush();
//Clear the buffer
buffer = new Byte[bytesToRead];
else
// cancel the download if client has disconnected
length = -1;
while (length > 0); //Repeat until no data is read
finally
if (stream != null)
//Close the input stream
stream.Close();
This is my download code.
Now I want the user to get the files directly from the download server.
Do not use site traffic to download the file.
And use server download traffic
thank you
Stream stream = null;
//This controls how many bytes to read at a time and send to the client
int bytesToRead = 10000;
// Buffer to read bytes in chunk size specified above
byte[] buffer = new Byte[bytesToRead];
// The number of bytes read
try
//Create a WebRequest to get the file
HttpWebRequest fileReq = (HttpWebRequest)HttpWebRequest.Create(Global.UrlVideoPrice + IdCourse + "//" + IdTopic+".rar");
//Create a response for this request
HttpWebResponse fileResp = (HttpWebResponse)fileReq.GetResponse();
if (fileReq.ContentLength > 0)
fileResp.ContentLength = fileReq.ContentLength;
//Get the Stream returned from the response
stream = fileResp.GetResponseStream();
// prepare the response to the client. resp is the client Response
var resp = System.Web.HttpContext.Current.Response;
//Indicate the type of data being sent
resp.ContentType = "application/octet-stream";
//Name the file
resp.AddHeader("Content-Disposition", "attachment; filename="" + Topic.fldName + ".rar"");
resp.AddHeader("Content-Length", fileResp.ContentLength.ToString());
int length;
do
// Verify that the client is connected.
if (resp.IsClientConnected)
// Read data into the buffer.
length = stream.Read(buffer, 0, bytesToRead);
// and write it out to the response's output stream
resp.OutputStream.Write(buffer, 0, length);
// Flush the data
resp.Flush();
//Clear the buffer
buffer = new Byte[bytesToRead];
else
// cancel the download if client has disconnected
length = -1;
while (length > 0); //Repeat until no data is read
finally
if (stream != null)
//Close the input stream
stream.Close();
This is my download code.
Now I want the user to get the files directly from the download server.
Do not use site traffic to download the file.
And use server download traffic
answered Mar 24 at 18:35
40454045
1
1
you can edit the question to add code
– 1SaeedSalehi
Apr 7 at 18:55
add a comment |
you can edit the question to add code
– 1SaeedSalehi
Apr 7 at 18:55
you can edit the question to add code
– 1SaeedSalehi
Apr 7 at 18:55
you can edit the question to add code
– 1SaeedSalehi
Apr 7 at 18:55
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55312071%2fdownload-files-from-the-download-server-with-the-help-of-php-and-mvc%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
1
Could you please provide code you have so far? And what did you try to accomplish your task?
– Alexander
Mar 24 at 11:41
@Alexander Actually He posted his code as a new answer
– osman Rahimi
May 5 at 10:08