简体   繁体   中英

C# / PHP => Upload file as Base64 and write it on disk

What i want to do:

I need to do a POST to a PHP Service using HttpWebRequest, and upload an image file as a Base64(can't change this) string along with other parameters and write the Base64 data in a database.

What i do:

  • So far i am able to upload the Base64 data representing an image
  • PHP side do receive the data and write it to the database

What doesn't work

  • When i am trying to read the Base64 data from the database and write it on the disk, it write the file but i am unable to open the file as an image

Thanks in advance!

The problem was actually in the Base64 string where in C# there was some '+' symbols and on the PHP side the '+' were removed for some reasons.

I just added the following line:

$data = str_replace(' ', '+', $data);

Now all work fine.

Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM