Jump to content

Recommended Posts

Well, I am using the following script to upload a form submitted file upload:
[code]
$imagefile=$_POST['imagefile'];
$filetype = $_POST['type'];

$ftp_user_name ='';
$ftp_user_pass ='';
$ftp_server ="";
$ftp_dir = "";
$web_dir = './files';
$web_location=$web_dir.$imagefile_name;

$destination_file=$ftp_dir.$imagefile_name;


if (file_exists($web_location))
{
header("location:http://"); //Checks to make sure the file doesn't already exist
}

//Connect to the FTP server
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
$upload = ftp_put($conn_id, $destination_file, $imagefile, FTP_ASCII);

$ch=ftp_site($conn_id,"chmod 777 ".$destination_file);
ftp_close($conn_id);

//verify file was written
if (file_exists($web_location))
        {
        @mysql_connect("db1.awardspace.com",$name,$lock);
        @mysql_select_db($database) or die( "Unable to select database");
        $sql="INSERT INTO user_files (file_name, file_size, file_type, file_path, file_rating) VALUES ('$imagefile_name','$imagefile_size','$type','$imagefile_path','0')";
        $r = mysql_query($sql);
        if(!$r) {
        $err=mysql_error();
        print $err;
        exit();}
        
        mysql_close();
        header("location:http://blah.com");
        }
else
        {
        echo "Could not create $web_location";
        }
//end if

?>
[/code]

Okay, I get this error from my hosting service (awardspace.com):
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
[mysite.awardspace.com] [Sat May 20 13:43:19 2006] [error] [client (IP address)] Premature end of script headers: upload.htm | file is writable by others upload.htm


Description: The server encountered an internal error or misconfiguration and was unable to complete your request.

Most common reasons for returning this error message are:

• File Upload Mode
When you upload Perl, CGI scripts via FTP you should use always ASCII mode. If you get "Error 500: Script Execution Failure" you should check whether your FTP client uses ASCII mode when uploading your scripts, because if it uses BINARY mode to upload your scripts they won't work on the server. The problem caused by wrong upload mode is associated with the way different operating systems handle the "end of line" character. Unix system uses a "line-feed" (LF), Windows uses a "carriage-return" (CR) and "line-feed" (LF) pair. That's why it is very important that you set the uploading mode to ASCII.

• File Permissions
When you upload scripts via FTP the file permissions are set by default to 755. If you get "Error 500: Script Execution Failure" you should check whether your scripts have 755 permissions. Otherwise your scripts have lower level of permissions and does not support execution upon request. The octal representation of the 755 permission is equal to the following textual format: -rwxr-xr-x
Most FTP clients support the CHMOD command which is used for setting file permissions. In case you have set improper permissions to your scripts, use your FTP client and set "Read, Write, Execute" permissions for the owner, "Read, Execute" permissions for the group and everyone else.

• Script Errors
This is the third well known reason for getting "Error 500: Script Execution Failure" upon execution of your scripts. Check your scripts for any obvious syntax or programming errors to make sure your code is not broken.


Remember: When you get a "Error 500: Script Execution Failure", you should always check for any file uploading problems (ASCII/BINARY) and the executable permission settings. Once those are checked and verified, it looks like there is a syntax error or some other problem in the script.
[/quote]

Now, I have set all the files I could think of to 777 permissions (upload.htm, upload.php, ./files/, ./members/)

I have no idea what could be wrong.
Link to comment
https://forums.phpfreaks.com/topic/10073-user-upload-form/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.