简体   繁体   中英

Upload error for PHP file - 500 internal server error?

I have upload script for file uploading from php which is configured to upload file on hosting server from godaddy. Same script I am using on different server domain it is not able to upload on that server which is also godaddy server. I have full access to the folder and server ftp but still didnt find out why this script is not working on that server. Anyone can find out why it is throwing 500 error.

<?php
        $ftp_server = "ftp.xxxxx.com";
        $ftp_username ="xxxx@xxxx.com";
        $ftp_password = "xxxxxxxxxxx";
        $destination_folder = "/upload/";
        $file_name = $_FILES["userfile"]["name"];
        $destination_file = $destination_folder.time().'_'.$file_name;
        $file = $_FILES["userfile"]["tmp_name"];

        // set up basic connection
        $conn_id = ftp_connect($ftp_server);

        // login with username and password
        $login_result = ftp_login($conn_id, $ftp_username, $ftp_password);
        // upload a file
        if (ftp_put($conn_id, $destination_file, $file, FTP_BINARY)) {
         echo "successfully uploaded $file\n";
        } else {
         echo "There was a problem while uploading $file\n";
        }

        // close the connection
        ftp_close($conn_id);

?>

Do you have shell access? If so, reconfig apache . It may sound not related to your problem, but this will solve it. I had this problem some time ago and rebuilding apache fixed it.

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