webdogjcn Posted May 20, 2006 Share Posted May 20, 2006 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 writtenif (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.htmDescription: 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 ModeWhen 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 PermissionsWhen 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-xMost 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 ErrorsThis 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. Quote Link to comment https://forums.phpfreaks.com/topic/10073-user-upload-form/ Share on other sites More sharing options...
webdogjcn Posted May 20, 2006 Author Share Posted May 20, 2006 solved by myself! Quote Link to comment https://forums.phpfreaks.com/topic/10073-user-upload-form/#findComment-37474 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.