如何使用AsyncTask PHP Android将图像上传到数据库?

时间:2017-02-24 23:48:42

标签: java php android json android-asynctask

我想知道使用AsyncTask将图像插入数据库的人......

这是我的Java代码:

 protected String doInBackground(String... params) {

               ........

                List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();

nameValuePairs.add(new BasicNameValuePair("image", image)); 

服务器端我正在使用数据库插入图像的URL ...

$path = "news/"."$sswebsite.png";

    $actualpath = "example.com"."$path";

    print_r($actualpath);

 $sql = "Insert into user(nome, email, password, state, last_login)
    values('$name','$email','$sswebsite','1',now(), '$actualpath')";

    $result = mysqli_query($link, $sql);



    if(!$result)
    {
        die("error in query #1". mysqli_error($link));
    }
    if($result)
    {
        echo 'success';
        print_r($image);
        file_put_contents($path,base64_decode($image));

图片路径不保存,图片不保存到文件夹...

如果我转到我在POSTMAN提交图片中测试的url_image

,则会出现服务器错误

未找到

The requested URL /admin/news/d41d8cd98f00b204e9800998ecf8427e.png was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

0 个答案:

没有答案