mirror of
https://github.com/Dvorinka/PPve.git
synced 2026-06-05 04:52:58 +00:00
Add files via upload
This commit is contained in:
@@ -60,7 +60,7 @@ type BannerContent struct {
|
|||||||
|
|
||||||
type BannerStyle struct {
|
type BannerStyle struct {
|
||||||
BackgroundColor string `json:"backgroundColor"`
|
BackgroundColor string `json:"backgroundColor"`
|
||||||
Color string `json:"color"` // Use color instead of textColor
|
TextColor string `json:"textColor"`
|
||||||
TextAlign string `json:"textAlign"`
|
TextAlign string `json:"textAlign"`
|
||||||
FontSize string `json:"fontSize"`
|
FontSize string `json:"fontSize"`
|
||||||
Padding string `json:"padding"`
|
Padding string `json:"padding"`
|
||||||
@@ -96,7 +96,7 @@ func initDefaultBanner() {
|
|||||||
Text: "Vítejte na našem webu!",
|
Text: "Vítejte na našem webu!",
|
||||||
Style: BannerStyle{
|
Style: BannerStyle{
|
||||||
BackgroundColor: "#f8d7da",
|
BackgroundColor: "#f8d7da",
|
||||||
Color: "#721c24",
|
TextColor: "#721c24",
|
||||||
TextAlign: "center",
|
TextAlign: "center",
|
||||||
FontSize: "18px",
|
FontSize: "18px",
|
||||||
Padding: "20px",
|
Padding: "20px",
|
||||||
@@ -171,7 +171,7 @@ func UpdateBannerHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
Link: r.FormValue("link"),
|
Link: r.FormValue("link"),
|
||||||
Style: style,
|
Style: style,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log the banner data for debugging
|
// Log the banner data for debugging
|
||||||
log.Printf("Parsed banner data: %+v", newBanner)
|
log.Printf("Parsed banner data: %+v", newBanner)
|
||||||
|
|
||||||
@@ -201,8 +201,9 @@ func UpdateBannerHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
http.Error(w, "Error creating file", http.StatusInternalServerError)
|
http.Error(w, "Error creating file", http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer tempFile.Close()
|
||||||
|
|
||||||
// Copy the file
|
// Copy the uploaded file to the destination file
|
||||||
if _, err := io.Copy(tempFile, file); err != nil {
|
if _, err := io.Copy(tempFile, file); err != nil {
|
||||||
log.Printf("Error saving file: %v", err)
|
log.Printf("Error saving file: %v", err)
|
||||||
http.Error(w, "Error saving file", http.StatusInternalServerError)
|
http.Error(w, "Error saving file", http.StatusInternalServerError)
|
||||||
@@ -236,9 +237,8 @@ func UpdateBannerHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the updated banner data
|
w.Header().Set("Content-Type", "application/json")
|
||||||
w.WriteHeader(http.StatusOK)
|
json.NewEncoder(w).Encode(banner)
|
||||||
json.NewEncoder(w).Encode(newBanner)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServeUploads handles serving uploaded files
|
// ServeUploads handles serving uploaded files
|
||||||
|
|||||||
Reference in New Issue
Block a user