小编hil*_*uff的帖子

如何在 UWP 中使用 httpClient.postAsync 上传图像或 bytes[]

所以我需要将图像以及其他一些字符串(例如名称)上传到我的 Mysql 数据库中...我能够将名称添加到 Mysql DB 中,但我无法对图像执行此操作。我将图像转换为字节 [],现在我被卡住了..这是我使用的代码

private Stream stream = new MemoryStream();
    private CancellationTokenSource cts;

    public MainPage()
    {
        this.InitializeComponent();
    }

    private async void buttonUpload_Click(object sender, RoutedEventArgs e)
    {
        FileOpenPicker open = new FileOpenPicker();
        open.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
        open.ViewMode = PickerViewMode.Thumbnail;

        // Filter to include a sample subset of file types
        open.FileTypeFilter.Clear();
        open.FileTypeFilter.Add(".bmp");
        open.FileTypeFilter.Add(".png");
        open.FileTypeFilter.Add(".jpeg");
        open.FileTypeFilter.Add(".jpg");

        // Open a stream for the selected file
        StorageFile file = await open.PickSingleFileAsync();

        // Ensure a file was selected
        if (file != null)
        {
            // …
Run Code Online (Sandbox Code Playgroud)

php c# mysql image win-universal-app

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

c# ×1

image ×1

mysql ×1

php ×1

win-universal-app ×1