我尝试使用file_put_contents上传目录中的图像,该文件已上传但已损坏,无法打开。这里是我的代码:使用file_put_contents上传过程中损坏的文件
define('UploadDir','../Dir/images');
$path = "image.png";
$data="..."; //image base64 string
$file = UploadDir ."/". $path;
$success = file_put_contents($file, $data);
echo $success ? $file : 'Unable to save the file.';
损坏怎么办?它有多大? '$ data'包含什么?这需要更多细节才能行得通。 –
'损坏'以什么方式? – 2013-07-10 10:54:33