Commit a55534d8 by Vuk Lazovic

UPLOAD sada radi

parent dedf10eb
......@@ -5,21 +5,13 @@
</component>
<component name="ChangeListManager">
<list default="true" id="6e82c7f1-3949-40e2-bc26-7eb50b36f993" name="Default Changelist" comment="login/logout/anonymous user...">
<change afterPath="$PROJECT_DIR$/src/main/resources/static/images/bgg_1.jpg" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/resources/templates/maintance.html" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/resources/templates/upload.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_18_9_2022__18_26__Default_Changelist_.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_18_9_2022__18_26__Default_Changelist_.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_18_9_2022__20_08__Default_Changelist_.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_18_9_2022__20_08__Default_Changelist_.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_19_9_2022__15_07__Default_Changelist_.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_19_9_2022__15_07__Default_Changelist_.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/app/config/Bezbednost.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/app/config/Bezbednost.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/app/usluga/web/MainKontroler.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/app/usluga/web/MainKontroler.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/templates/about.html" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/templates/agents.html" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/templates/blog-single.html" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/templates/blog.html" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/templates/contact.html" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/templates/dodaj.html" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/templates/dodaj.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/templates/images/bg_1.jpg" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/templates/index.html" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/templates/index.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/templates/property-single.html" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/templates/property-single.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/templates/property.html" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/templates/property.html" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
......@@ -207,6 +199,7 @@
<workItem from="1663587883995" duration="11000" />
<workItem from="1663589644471" duration="4472000" />
<workItem from="1663594548080" duration="456000" />
<workItem from="1663598082766" duration="1582000" />
</task>
<task id="LOCAL-00001" summary="dodata ulogovana verzija">
<created>1663501497955</created>
......
......@@ -72,7 +72,9 @@ public class Bezbednost extends WebSecurityConfigurerAdapter {
.clearAuthentication(true)
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/")
.permitAll();
.permitAll()
.and()
.csrf().disable();
}
}
package app.usluga.web;
import org.springframework.http.HttpStatus;
import app.model.Oglas;
import app.usluga.OglasUsluga;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import java.io.File;
import java.io.IOException;
import java.util.List;
@Controller
public class MainKontroler {
@PostMapping("/upload")
public ResponseEntity<?> handleFileUpload (@RequestParam("file")MultipartFile file)
{
String fileName=file.getOriginalFilename();
try {
file.transferTo(new File("C:\\Users\\vuk\\Desktop\\awesomelands\\src\\main\\resources\\static\\images\\uploads\\"+fileName));
} catch (IOException e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
return ResponseEntity.ok("file uploaded successfully");
}
@GetMapping("/login")
public String prikaziLogin() {
return "login";
......
<!DOCTYPE html>
<html>
<html xmlns:th="https://www.thymeleaf.org">
<html >
<head>
<meta charset="UTF-8">
<title>Dodaj stan</title>
......@@ -2150,6 +2150,30 @@ template {
</nav>
<!-- END nav -->
<input id="fileupload" type="file" />
<button id="upload_button" onclick="uploadFile()"> UPLOAD </button>
<script>
async function uploadFile()
{
let formData = new FormData();
formData.append("file",fileupload.files[0]);
let response = await fetch('/upload',{
method:'POST',
body:formData
});
if (response.status==200)
{
alert("DOBRO JE");
}
else
{
alert("NIJE DOBRO");
}
}
</script>
<section class="home-slider owl-carousel">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment