Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't upload the photo from mobile (IOS) #4734

Open
1 task done
b0rygo opened this issue Jan 18, 2025 · 0 comments
Open
1 task done

Can't upload the photo from mobile (IOS) #4734

b0rygo opened this issue Jan 18, 2025 · 0 comments

Comments

@b0rygo
Copy link

b0rygo commented Jan 18, 2025

Duplicate Check

Describe the bug

Hi!
Can't upload a file from mobile to the app! It shows ErroNo2 No file or directory.

Code sample

import flet as ft
import shutil

# Funkcja uruchamiająca wybór pliku
def upload_image(result, page):
    if result.files and len(result.files) > 0:
        file = result.files[0]
        # Przesyłanie pliku i analiza obrazu
        analyze_and_upload_image(file, page)
    else:
        page.add(ft.Text("Nie wybrano pliku.", color=ft.colors.RED))


# Funkcja do analizy obrazu
def analyze_and_upload_image(file, page):
    try:
        # Generowanie unikalnych nazw plików na podstawie czasu
        input_image_path = f"images/{file.name}"
        output_image_path = f"results/{file.name}"

        # Zapisz plik w folderze aplikacji
        with open(input_image_path, "wb") as f:
            shutil.copy(file.path, input_image_path)

        # Dodanie obrazu do strony i wyśrodkowanie go
        page.add(ft.Image(src=input_image_path, width=300, height=400, fit=ft.ImageFit.CONTAIN))

    except Exception as e:
        # Wyświetlenie błędu w aplikacji
        page.add(ft.Text(f"Błąd: {str(e)}", color=ft.colors.RED))


# Funkcja uruchamiająca stronę i przycisk do otwarcia FilePicker
def pyShotPage(page: ft.Page):
    page.clean()

    # Inicjalizacja FilePicker z odpowiednimi ustawieniami
    file_picker = ft.FilePicker(on_result=lambda e: upload_image(e, page))

    # Dodanie FilePicker do overlay
    page.overlay.append(file_picker)

    # Przycisk do wybrania pliku
    page.add(
        ft.Column(
            [
                ft.Text("Prześlij zdjęcie do analizy", size=16, weight=ft.FontWeight.BOLD, text_align="center"),
                ft.ElevatedButton(
                    "Prześlij zdjęcie",
                    width=200,
                    height=50,
                    style=ft.ButtonStyle(
                        shape=ft.RoundedRectangleBorder(radius=10),
                        padding=20,
                    ),
                    on_click=lambda _: file_picker.pick_files(
                        allow_multiple=False, file_type=ft.FilePickerFileType.IMAGE
                    ),
                ),
            ],
            alignment=ft.MainAxisAlignment.CENTER,
            horizontal_alignment=ft.CrossAxisAlignment.CENTER,
            expand=True,
        )
    )


# Uruchamiamy aplikację
ft.app(target=pyShotPage)

To reproduce

  1. Run the code from PC! WORKS
  2. RUN AT YOUR MOBILE AND THE BUG WILL SHOW!

Expected behavior

No response

Screenshots / Videos

Captures

Image

Operating System

macOS

Operating system details

Ios 18.2

Flet version

Version: 0.25.2

Regression

No, it isn't

Suggestions

No response

Logs

Logs
[Paste your logs here]

Additional details

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant