Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I want to save file send by client using PHP server socket. I am newbie to PHP socket programming.
Does anyone know possible options?
-SAM
Have look at this snippet, it recieves a file sent to the php socket server then saves it on the server:
http://www.example-code.com/php/socket_receiveFile.asp
Alternatively you could develop your own solution, but then you'd have to:
Create a binary structure for what each request looks like. For example you need to create predefined header that the server can read to know what type of request it is, what type of data it is, where the data starts in the file and what to do with the data.
Create a binary parser which will read the header and which can take the binary data and turn it into a file and then save it.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 days ago.
Improve this question
I am using twilio to send and received sms and mms.
And in this we get the mms replay from customer and with sms we get image link form twilio, below are the example:
http://media.twiliocdn.com.s3-external-1.amazonaws.com/AC70edf98a96171fd173a06c91f9866e44/7f05c776f706eb9265f74f2236ac146c
And in this we want to download this image on our server. so can any one have any idea how to do this?
I encountered a similar scenario in this blog post where I manipulate a file from the URL as stored by Twilio using my local filesystem before sending it back.
The snippet there in Python:
if request.form['NumMedia'] != '0':
filename = request.form['MessageSid'] + '.jpg'
f = open(filename, 'wb')
f.write(requests.get(request.form['MediaUrl0']).content)
f.close()
I check parameters to make sure that the media is indeed there with NumMedia and I believe in PHP you would use the fopen() function then $_REQUEST[‘MediaUrl0′] to retrieve the image and whatever the PHP equivalent is for binary response content in the python requests library to write the non-text body.
Hope this helps!
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I think the title is explaining perfectly.
How I can deliver big REMOTE files to client with resume capability through PHP?
You likely wouldn't want to use PHP for that, since it's not really made for this kind of task.
For Resume capability, your script needs to be able to read and act properly upon the Range: HTTP request header the client sends, as well as correctly serve a Content-length: header at least.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
My C++ program communicates to my PHP server through a TCP socket.
Data is sent on the server at periodic intervals.
I want the Data sent on the server to be displayed on my HTML page.
I am new to HTTP/PHP programming. How can I achieve this.
Thanks in advance.
There are a lot of ways to do this, the most simple should be this one (if your c++ program run out of the server):
create a "upload.php" file in your server with:
<?php
$a = $_POST["data"];
//$a contains all your data
?>
send a POST message to
http://yourserver/upload.php
from your c++ program with 'data' parameter containing your data message. You can use libcurl to achieve this. Here is an example How do you make a HTTP request with C++?
c++ to PHP use Socket
PHP to HTML use HTTP
To run PHP you will need to install apache.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I know that the usual method for handling a form with PHP is to POST to a script like this:
echo("<form action='handleForm.php' method='post'>");
it possible to POST directly into a text file like this:
echo("<form action='formData.txt' method='post'>");
?
If you want to append the text into the file, it won't.
POST is a type of request to the server to send data. HTTP server will answer with your txt file, and the browser will show that. As the server as default is not able to run any kind of txt codes, nothing will happen. You can set up different codes, how to handle these files.
There are a lot of types of request, read further if you interested in.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want to send the doc and pdf file to the MySQL database using php from my android application.
I have no idea about it. What shoud i write in android and php file?
Please guide me if anyone have code?
Thanking you.
You have two options:
1) Store it in a field with a BLOB data type. I really do not advise this in any way and is only listed as the first option because it pertains directly to your question.
SO has good coverage of this already Storing files in SQL Server
2) Move the file to a folder and store the file path. This is the preferred option by mmmm everyone. Use move_uploaded_file and if you are unsure of how to setup an html form take a look at W3C PHP File Upload