Compare commits

...

3 commits

Author SHA1 Message Date
2e9d90a0ae added visual feedback to website and added a response in the server 2025-05-22 23:02:02 +02:00
2b77a349fa Merge remote-tracking branch 'origin/master'
# Conflicts:
#	main.cpp
#	netlib
2025-05-22 22:22:04 +02:00
0c00146151 the files are processed in chunks 2025-05-16 06:01:13 +02:00
3 changed files with 34 additions and 2 deletions

View file

@ -5,6 +5,7 @@
#include <print> #include <print>
#include <fstream> #include <fstream>
#include <map> #include <map>
#include <filesystem>
int atoi_newline(const char *data) int atoi_newline(const char *data)
{ {
@ -337,6 +338,7 @@ int main()
char *end = search_substring(chunk, final_boundary.c_str(), file_size); char *end = search_substring(chunk, final_boundary.c_str(), file_size);
write_file(filename, chunk, end); write_file(filename, chunk, end);
free(chunk); free(chunk);
netlib::send_packet(std::make_tuple(std::string("HTTP/1.1 200 OK\r\n")), user);
} }
else else
{ {

2
netlib

@ -1 +1 @@
Subproject commit 5a4d644261435c9ea6ca40369f55ce849fbab3ae Subproject commit 344f771aa83755fa6acdcd74a621362adc1fd5b7

View file

@ -20,6 +20,11 @@
background-color: #fff; background-color: #fff;
transition: background-color 0.3s, border-color 0.3s; transition: background-color 0.3s, border-color 0.3s;
} }
#drop_zone.dragover
{
border-color: green;
background-color: #e0ffe0;
}
</style> </style>
</head> </head>
<body> <body>
@ -29,9 +34,12 @@
ondrop="dropHandler(event);" ondrop="dropHandler(event);"
ondragover="dragOverHandler(event);" ondragover="dragOverHandler(event);"
ondragenter="dragEnterHandler(event);" ondragenter="dragEnterHandler(event);"
ondragleave="dragLeaveHandler(event);"
> >
</div> </div>
<div id="status"></div>
<script> <script>
const dropZone = document.getElementById('drop_zone'); const dropZone = document.getElementById('drop_zone');
@ -67,9 +75,18 @@
} }
function dragEnterHandler(ev) function dragEnterHandler(ev)
{ {
document.getElementById('drop_zone').classList.add('dragover');
ev.preventDefault(); ev.preventDefault();
} }
function dragLeaveHandler(ev)
{
if (ev.target === document.getElementById('drop_zone'))
{
document.getElementById('drop_zone').classList.remove('dragover');
}
}
function uploadFile(file) function uploadFile(file)
{ {
@ -79,12 +96,25 @@
const formData = new FormData(); const formData = new FormData();
formData.append('uploadedFile', file, file.name); formData.append('uploadedFile', file, file.name);
document.getElementById('status').textContent = 'se esta subiendo el archivo';
fetch(url, fetch(url,
{ {
method: 'POST', method: 'POST',
body: formData, body: formData,
}) })
.then(
response =>
{
if (response.ok)
{
document.getElementById('status').textContent = 'se subio el archivo';
}
else
{
document.getElementById('status').textContent = 'Hubo un error subiendo el archivo';
}
}
)
} }
</script> </script>