简体   繁体   中英

Converted base64 file not working in PHP

I'm unable to convert base64 from an iphone device using PHP.

The file is corrupted after executing the following code:

file_put_contents($fileName, base64_decode($base64_data));

Example Base64 for a PNG file i used:

iVBORw0KGgoAAAANSUhEUgAAAAoAAAANCAYAAACQN/8FAAAAHGlET1QAAAACAAAAAAAAAAcAAAAoAAAABwAAAAYAAAFEmBTn/wAAARBJREFUKBUUzD1Lw0AAh/H7In4AcRQcBHFydXJ1FRdnd8FBCkIRJ7FTKZRaNKCgRWPSgk2rvWuS5u3yfpeL5FP8rcOz/XiI6/ODkGeMJ4Uqiko2TSPrSskoLqQXJMoLU/ZviONG0zVEmpZQlcJkVcOwBbI0h+9zLO1gnT8llK1sP+DI8xKn/Rr7t7/Yvalx0pMIQ46fhQNrTh0ym1OWhAE6psBmq0acSThcYuOyRkfPsKQUhmkxYk4sFnsuzvoCx10FkUYQSYTDuwrngwx0ZuH1TWdk9G4we/GNCy3FTluhTELEUYCtlsKV5mOs63h4fGbkSXthum7g84ti+1ri6F6sbwJ77RyjjzGGQw3d3oD9AQAA//9PvKCmAAAAyUlEQVRjWLJs1fn1G7b8371r9/+dB078b1596X/NktP/N2zd/X/VqtX/58xb/H/23EWXGebMXXRx9eoN/9dv2Pp/x/ad/w/t2/d/x5bN/5csXfF/7vwl/2fMmv9/0pSZ0ximTp9zvLSs6r+7h9chNw/vrR6e3vs9PL0OuLp5HHFycV+bmJyW0te3ipOhvbO/3snZ7T8DA0MQEIsBsREQOwFxIBDrADEElJd38Ds7u8zl4eEBSSIDRiAHhBHA3t4pUlhY2AUhgskCAHZCN1W9mev8AAAAAElFTkSuQmCC

Help mee.... the above code working for base64 from other devices..

Your data seems to be correct. It gives this image => 这个图片 .

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