Upload
This commit is contained in:
parent
59f830667d
commit
0fc9efb035
5
.idea/.gitignore
vendored
Normal file
5
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
12
.idea/InstagramFormatterWeb.iml
Normal file
12
.idea/InstagramFormatterWeb.iml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/InstagramFormatterWeb.iml" filepath="$PROJECT_DIR$/.idea/InstagramFormatterWeb.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
21
index.html
Normal file
21
index.html
Normal file
@ -0,0 +1,21 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Instagram Formatter</title>
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Instagram Formatter</h1>
|
||||
<form id="uploadForm">
|
||||
<input type="file" id="imageInput" name="image" accept="image/*" required>
|
||||
<button type="submit">Upload and Format</button>
|
||||
</form>
|
||||
<a id="card" style="display: none;">Download Formatted Image</a>
|
||||
<div id="preview"></div>
|
||||
</div>
|
||||
<script src="script.js"></script>
|
||||
</body>
|
||||
</html>
|
42
script.js
Normal file
42
script.js
Normal file
@ -0,0 +1,42 @@
|
||||
document.getElementById('uploadForm').addEventListener('submit', async function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
const formData = new FormData();
|
||||
const imageInput = document.getElementById('imageInput').files[0];
|
||||
|
||||
if (!imageInput) {
|
||||
alert("Please select an image to upload.");
|
||||
return;
|
||||
}
|
||||
|
||||
formData.append('image', imageInput);
|
||||
|
||||
try {
|
||||
const response = await fetch('https://dev.nevets.tech/igformatter/upload', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Image upload failed');
|
||||
}
|
||||
|
||||
const arrayBuffer = await response.arrayBuffer();
|
||||
downloadImage(arrayBuffer);
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error:', error);
|
||||
alert('There was an error processing your image.');
|
||||
}
|
||||
});
|
||||
|
||||
function downloadImage(arrayBuffer) {
|
||||
const blob = new Blob([arrayBuffer], { type: "image/png" });
|
||||
const cardElement = document.getElementById("card");
|
||||
|
||||
let urlCreator = window.URL || window.webkitURL;
|
||||
cardElement.href = urlCreator.createObjectURL(blob);
|
||||
cardElement.style.display = 'unset';
|
||||
cardElement.download = "formatted_image.png";
|
||||
cardElement.click();
|
||||
}
|
57
styles.css
Normal file
57
styles.css
Normal file
@ -0,0 +1,57 @@
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background-color: #f4f4f4;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.container {
|
||||
background: white;
|
||||
padding: 20px;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.1);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin-bottom: 20px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
input[type="file"] {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
button {
|
||||
background-color: #1da1f2;
|
||||
color: white;
|
||||
padding: 10px 20px;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: #0a85d9;
|
||||
}
|
||||
|
||||
#card {
|
||||
margin-top: 20px;
|
||||
display: inline-block;
|
||||
padding: 10px 20px;
|
||||
background-color: #28a745;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#card:hover {
|
||||
background-color: #218838;
|
||||
}
|
||||
|
||||
#preview {
|
||||
margin-top: 20px;
|
||||
}
|
Loading…
Reference in New Issue
Block a user