我想使用 post 将图像从 localhost 传输到服务器。我的 php 有问题,这里捕捉到图像是我的代码:
$string = "iVBORw0KGgoAAAANSUhEUgAAAO0AAAA2CAIAAACk1ok0AAAAAXNSR0IArs4c6QAAAARnQU1BAACx
jwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAUJSURBVHhe7Z2hVuwwEIaRSBxIBA+ARCKRSCQS
icQhkUgkj4BEIpFIHgGJRMJ/T+6dk9uybZr8k06ys2rhJNOZf74mkzbt7nz7xxVoX4Gd9kPwCFyB
b+fYIehBAee4hyx6DM6xM9CDAs5xD1n0GJxjZ6AHBZzjNrL4/Px8enr6+PjYhrvVvVyfY+Tm8PBw
J/rgT6WEPT09hWPpHUIpgwcHB3B7d3c3wz7OgYHCsdqWv6enaU2OxwSLpnkJm87xx8cHzKoeIgOy
2S5vb2+Xl5fi9mz7cYNGIQ4hJ5JQm+PEseHq6iojYXGXz8/P29vbiRSWH6LQw9nuLy8vA/8vLi5m
e40b3N3dWR50p31LTFM9jl9fX+/v78P8OPggPV9fXxkZ+rULBrDr6+u9vb1NAqG6YB1Lz85g9kAs
Z2dnRJW4npdMFxRPFDlGJkDMzc0NFiibkDo6OirMTeIALw6ABopwqkYwmeDcDj7jzMeYhLFZ9YiF
xjvkeBFYhfKh+0TlkL5KKHeDaOHh4SGeTOzPHhiwOuR4E1j4P8YYlBYoMIhhj4u/JgawTdyjpo/n
riZmD1Rxwefj42Pi+bzIFL+uiMFCRYG6AiMKTtnYLSLHMNvNtVWMxKJMQ5OJrHlWnDr4HKecRlyO
S66tpnhbrY0AYXlJN1aDm808tXvg2IKOeeoPekkghWtfijPpRizovwLHuC7GjZxrLT1/9JaNBmLB
7docY6TBaiBEjuqZgoIFHbc5EAv61+ZY1uO43/j+/r7N6bdZaGZkZBs5lqUMLmtkSPZrFws6UmJp
NBALbtcejzVi1rBJ4XKpkRYDQaFowW3neClsiu0tALE0PGxaDG7jgvfSvsT2zjFRzFJTLXJ8cnIS
3CYWihk6OscZov3tEm8Npdx+a45juYSKVfvglm2+rFk9u+JYOFjlS+KO74k0Ncex7Kw4Pz/Pwo/W
yTmmMZ+447snjmVfHra40JDMMuQcF3FMKSckcc2Nx3Yc7orjrDPZUCc7WCSKYsdh5zgxZTWayWOw
uOtZ43jFx3COmeePHTULwZBl0+qXsVICwaNWFq4cB1eZPKUEr8Gchs2UWOhtcG8MO49DOOVXP+ju
DQxiXRtcxaMS2seate8cz0pUtYGR27wpMctWGTyoltJetY1zrCpvjnGZXpReqpTj0299TE2DzjEr
rTQ7strDF8soO8d/FKClHTX+vw/R5oqm4gd1LVfJpmRn8jSbe6UVrilBZ0VIaRCjnNJ+lTamZK/K
sdIK15SgLKSkusBeHJZNrh1TslflWGmFa0pQFivyXqzVt+BsisiU7FU5VopcySyLyDw78VPl627t
dY6HCigBp2Q2jz9iL3ntsc3VninZfTwmgjdjavYNjtg9F79a0/g9EeeYfPKYEnSC5ZL3wtc725KP
ZEp2MlLTIihFLkt7m3WkaFLyXniDLxFVymbyefRfwx44lm1iNuvI9MSEN+nv7+8LIrNfuBv5011F
S+eYfPIYryMXwYHGGeXHKjQ7x2SOrY0NS8EdtB+XH1j8haF6AvH6c9H2ciyFbGGmx92be5KCokBM
fPlTrktd2l6Og+4aisdPUrTyUNBSbqy1316O9TIRP0kR9MUUDLjpLwfp5jccynOhN7tm+MYvVTOc
oHQZozy72M9uUL8YpUjENaI3u2b42Q/HCB4oxz9hm41pSscMrb2LngJdcRzLhN8Okhffp3C5qI1G
ia+X422w/AO/8BouFT8hjwAAAABJRU5ErkJggg==";
$string 是我的示例图片
$img2 = base64_decode($string);
$img = imagecreatefromstring($img2);
if($img != false)
{
//this is the location and name you can use date time to create name if you want
//also put the path before the image if you want to save it to a folder ex. 'pics/image.jpg'
$path = "sample_upload/images/" . date("Y_m_d_H_i_s") . ".jpg";// put path here
$sampledate = date("Y_m_d_H_i_s");
echo $sampledate;
imagejpeg($img, $path.''.$sampledate.'.jpg');
//they can put db query here if they like to insert img path and email
}
错误是 [31-Aug-2013 13:56:49 Asia/Manila] PHP 致命错误:调用未定义函数 imagecreatefromstring()