简体   繁体   中英

Uploading image file from website on yahoo server causes 410 gone error message when trying to access it

I have a form that lets users upload a photo of themselves. This seems to work. The photo does exist on the server once uploaded. When I try to access the file I get a "403 forbidden - you don't have permission to access this url on this sever" and also I get "Additionally, a 410 Gone error was encountered while trying to use an ErrorDocument to handle the request."

This is the code I have for uploading the image.

$target_path = "images/";

$target_path = $target_path . basename( $_FILES['uploadpic']['name']);

if(move_uploaded_file($_FILES['uploadpic']['tmp_name'], $target_path))
 {
    echo "The file ". basename( $_FILES['uploadpic']['name']). " has been uploaded";
 } 
else
 {
echo "There was an error uploading the file, please try again!";
 }

There's chmod() for Unix-like systems.

Be warned that your script will unconditionally overwrite the destination file. Maybe this is what you wanted, but consider what could happen if that $target_path is Web-accessible and a malicious uploads a new 'index.php' or whatever.

You must check the configuration of your destination path:

403 forbidden -> You don't have permission to enter that directory...

You need to change the chmod of that directory...

410 Gone error -> The server couldn't found the proper error document to present with the 403 forbidden message (at htaccess you can set this up)

If you don't want this message, you need to create a custom one...

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