in Education by
I have made a chatroom where users can messages to each other but I want to add a upload file feature, I have found how to do this: import tkinter as tk from tkinter import filedialog def UploadAction(event=None): filename = filedialog.askopenfilename() print('Selected:', filename) root = tk.Tk() button = tk.Button(root, text='Open', command=UploadAction) button.pack() root.mainloop() but I do not know how to send the file to the other users so that they can download it so could someone please help me JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Although this subject is out of topic (this question is actually about sockets and not tkinter), not asked correctly (see how to ask), and possibly a duplicate of Send a file through sockets in Python , here is a short description of what you should have done for the sake of others. Generally speaking, transferring files is a broad subject to deal with, from compression, file transfer, checksums, etc. We'll concentrate on how to transfer data in general between two computers using sockets because I see that this is your intention. Depending on your implementation, you should send a request for the other user for a file transfer. Then, if accepted (acceptance/rejection should be a response from the other user), start transferring the file. In the first step, just send an header that describes the file transfer (file name, size, etc.) Then, when accepted, you send a bytes stream of the content. You can read files as bytes with open(file,'rb') and open(file,'wb') for read/write, respectively. Its a good practice to communicate with headers for metadata, check availability, manage balance, etc. Note that using socket is low-level interface for data transfer. I wouldn't reinvent; I would learn by examples. See Sending a file over TCP sockets in Python post that shown a nice concise code that transfer files. The solution for his problem (termination of a transfer) is given in the answers of that post, but the code is generally OK. Few more minutes on Google search will result with explained tutorials. Have the best luck with you application!

Related questions

0 votes
    I have a custom PyPi package. It is installed under Pyhon\Python38\Lib\site-packages\myCustomPackage. In the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    I want to log the user session. Currently the code is as follows (setting formatter and handlers is omitted ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 11, 2022 in Education by JackTerrance
0 votes
    I want to log the user session. Currently the code is as follows (setting formatter and handlers is omitted ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 30, 2022 in Education by JackTerrance
0 votes
    I want to log the user session. Currently the code is as follows (setting formatter and handlers is omitted ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 23, 2022 in Education by JackTerrance
0 votes
    I want to log the user session. Currently the code is as follows (setting formatter and handlers is omitted ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 12, 2022 in Education by JackTerrance
0 votes
    I have a legit situation like this where I need to implement a method that changes the incoming object ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    Pandas tidy data, spread variables from one column, gather from another My Problem I need to turn the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 14, 2022 in Education by JackTerrance
0 votes
    In a script where I create many figures with fix, ax = plt.subplots(...), I get the warning ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 13, 2022 in Education by JackTerrance
0 votes
    Pandas tidy data, spread variables from one column, gather from another My Problem I need to turn the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 12, 2022 in Education by JackTerrance
0 votes
    Pandas tidy data, spread variables from one column, gather from another My Problem I need to turn the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 10, 2022 in Education by JackTerrance
0 votes
    Is there a way to specify the color a text is printed within Idle for Python 3.2? I'm looking ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 25, 2022 in Education by JackTerrance
0 votes
    Is there a way to specify the color a text is printed within Idle for Python 3.2? I'm looking ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 25, 2022 in Education by JackTerrance
0 votes
    I'm creating a button in Tkinter and I wanted to create rounded corners, other posts suggested using an ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    I'm Running Ubuntu 16.04 LTS with Python 3.6.8 and I have the following code that allows me to ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 8, 2022 in Education by JackTerrance
0 votes
    I am reading a yaml file like so in Python3: def get_file(): file_name = "file.yml" properties_stream ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 1, 2022 in Education by JackTerrance
...