Uploading file to server with android

后端 未结 1 846
北海茫月
北海茫月 2021-01-20 04:14

I have been working on an app on android that should grab an image from the sd card and then upload it to my server. I was able to get the pic to upload to a server using th

相关标签:
1条回答
  • 2021-01-20 05:04
     <?php
        $target_path1 = "/var/www/images/"
        $target_path1 = $target_path1 . basename( $_FILES['uploaded_file']['name']);
        if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $target_path1)) { 
            echo "Success";
        } else {
            echo "fail";
        }
     ?>
    

    It looks like you were referencing a relative directory: var/www/images/ which, if your php file was in /var/www/ to begin with would be pointing to /var/www/var/www/images/ which I doubt is what you were intending.

    Just change $target_path1 to make it an absolute path /var/www/images/

    0 讨论(0)
提交回复
热议问题