Compare commits
3 commits
afaad60e50
...
2e9d90a0ae
Author | SHA1 | Date | |
---|---|---|---|
2e9d90a0ae | |||
2b77a349fa | |||
0c00146151 |
3 changed files with 34 additions and 2 deletions
2
main.cpp
2
main.cpp
|
@ -5,6 +5,7 @@
|
|||
#include <print>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
#include <filesystem>
|
||||
|
||||
int atoi_newline(const char *data)
|
||||
{
|
||||
|
@ -337,6 +338,7 @@ int main()
|
|||
char *end = search_substring(chunk, final_boundary.c_str(), file_size);
|
||||
write_file(filename, chunk, end);
|
||||
free(chunk);
|
||||
netlib::send_packet(std::make_tuple(std::string("HTTP/1.1 200 OK\r\n")), user);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
2
netlib
2
netlib
|
@ -1 +1 @@
|
|||
Subproject commit 5a4d644261435c9ea6ca40369f55ce849fbab3ae
|
||||
Subproject commit 344f771aa83755fa6acdcd74a621362adc1fd5b7
|
32
test.html
32
test.html
|
@ -20,6 +20,11 @@
|
|||
background-color: #fff;
|
||||
transition: background-color 0.3s, border-color 0.3s;
|
||||
}
|
||||
#drop_zone.dragover
|
||||
{
|
||||
border-color: green;
|
||||
background-color: #e0ffe0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -29,9 +34,12 @@
|
|||
ondrop="dropHandler(event);"
|
||||
ondragover="dragOverHandler(event);"
|
||||
ondragenter="dragEnterHandler(event);"
|
||||
ondragleave="dragLeaveHandler(event);"
|
||||
>
|
||||
</div>
|
||||
|
||||
<div id="status"></div>
|
||||
|
||||
<script>
|
||||
const dropZone = document.getElementById('drop_zone');
|
||||
|
||||
|
@ -67,9 +75,18 @@
|
|||
}
|
||||
function dragEnterHandler(ev)
|
||||
{
|
||||
document.getElementById('drop_zone').classList.add('dragover');
|
||||
ev.preventDefault();
|
||||
}
|
||||
|
||||
function dragLeaveHandler(ev)
|
||||
{
|
||||
if (ev.target === document.getElementById('drop_zone'))
|
||||
{
|
||||
document.getElementById('drop_zone').classList.remove('dragover');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function uploadFile(file)
|
||||
{
|
||||
|
@ -79,12 +96,25 @@
|
|||
const formData = new FormData();
|
||||
|
||||
formData.append('uploadedFile', file, file.name);
|
||||
|
||||
document.getElementById('status').textContent = 'se esta subiendo el archivo';
|
||||
fetch(url,
|
||||
{
|
||||
method: 'POST',
|
||||
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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue