biwerw Posted December 28, 2009 Share Posted December 28, 2009 I'm using a script that uploads to an FTP thru the web. I have adjusted a lot of the php.ini settings to suit larger files. My problem is that it seems to work fine in Firefox but not in Safari. Safari will just hang there and the file will never reach the ftp. I've tried clearing the cache, still no luck. Any ideas? Link to comment https://forums.phpfreaks.com/topic/186519-safari-vs-firefox/ Share on other sites More sharing options...
sKunKbad Posted December 28, 2009 Share Posted December 28, 2009 Share some code. Link to comment https://forums.phpfreaks.com/topic/186519-safari-vs-firefox/#findComment-985042 Share on other sites More sharing options...
biwerw Posted December 28, 2009 Author Share Posted December 28, 2009 Here is the php file that is run once the upload button is pressed on the form. I have a lot of the php settings commented out since i have adjusted them in my cgi-bin/php.ini file. <? Echo "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> <html xmlns='http://www.w3.org/1999/xhtml'> <head> <meta http-equiv='Content-Type' content='text/html; charset=UTF-8' /> <meta http-equiv='cache-control' content='no-cache'> <meta http-equiv='pragma' content='no-cache'> <title>Page Title</title> <!--CSS--> <link href='../assets/css/style.css' type='text/css' rel='stylesheet' title='print' media='screen' /> <!--JAVASCRIPT--> <!--[if lte IE 6]> <script src='http://ie7-js.googlecode.com/svn/version/2.0(beta3)/IE8.js' type='text/javascript'></script> <![endif]--> </head> <body> <div id='layout'> <div id='layout-top'> <div id='top-nav'> <p><a href='upload.php'>« BACK</a> | <a href='../logout.php'>LOGOUT</a></p> </div><!--top-nav end--> </div><!--layout-top end--> <br class='clear' /> <div id='layout-header'> <div class='mlab-type' align='center'><img src='../assets/images/logo-original-trans.png' alt='Logo' /></div> </div><!--layout-header end--> <div id='layout-content'> <div id='content-top'></div> <div id='content-middle'> <div align='center'> <img src='../assets/images/label-thankyou-trans.png' alt='Thank You' style='margin:0 auto;' /> "; //uses $_FILES[] global array //see manual for older PHP version info //This function will be used to get the extension from the filename Function get_extension($file,$length=-1){ $p = strrpos($file,"."); $p++; If($length!=-1){ $ext = substr($file,$p,$length); } If($length==-1){ $ext = substr($file,$p); } $ext = strtolower($ext); Return $ext; } //reset time limits to not time out on larger files //Ini_set('max_execution_time',0); //Ini_set('max_input_time',0); Ini_set('set_time_limit',0); ?> <? //check to see if we have submited yet If($_POST["submit"]!="submit"){ //not yet so lets make the form ?> <? } //see if we have submited and that the files array has been set If(($_POST["submit"]=="submit")&&(is_array($_FILES['userfiles']))){ $ftp_user_name="FTPUSERNAME"; //change to ftp username $ftp_user_pass="FTPPASS"; //change to ftp password $ftp_server="FTPURL"; //change to ftp url $ftp_dump_dir="/upload-general"; //change to destination directory //Not good practice, but here anyway //change to suit your needs //also some have to be set in the ini //for this to correctly work //2meg max //Ini_set("upload_max_filesize","1000M"); //turn on file uploads //Ini_set("file_uploads","1"); //set your temp dir Ini_set("upload_tmp_dir","/tmp"); //set post size large enough to accomidate //3 100meg files and some overhead //Ini_set("post_max_size","1000M"); //go through all the files For($x=0;$x<count($_FILES['userfiles']['name']);$x++){ //now we do some file checking //check to see if file is there If($_FILES['userfiles']['name'][$x]!="none"){ //file has a name //check filesize If($_FILES['userfiles']['size'][$x]!=0){ //file is larger than 0 bytes //Check to see if it is uploaded If(is_uploaded_file($_FILES['userfiles']['tmp_name'][$x])){ //file has been uploaded! //let the user know their file has be uploaded Echo "<p>".$_FILES['userfiles']['name'][$x]." uploaded successfully!</p>"; //conect to ftp server $conn_id = ftp_connect($ftp_server); // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // check connection If ((!$conn_id) || (!$login_result)) { Echo "<p>FTP connection has failed!</p>"; Echo "<p>Attempted to connect to $ftp_server for user $ftp_user_name</p>"; Exit; } else { //Echo "<p>Connected to $ftp_server!</p>"; //set PASV mode If(!ftp_pasv($conn_id,TRUE)){ Echo "<p>Could not enter PASV mode!</p>"; } //rename to file#_date.Ext $filename = $_FILES['userfiles']['name'][$x]; //$filename.= ".".Get_extension($_FILES['userfiles']['name'][$x],3); //change directory If (@ftp_chdir($conn_id, $ftp_dump_dir)) { //maybe you want to make sure we are in the correct directory //Echo "Current directory is now : ", ftp_pwd($conn_id), "\and"; } else { //you want to know if it didn't work Echo "Couldn't change directory\and"; } //upload the file and let the user know what happened If(ftp_put($conn_id,$filename,$_FILES['userfiles']['tmp_name'][$x],FTP_BINARY)){ //Echo "<p>File ".$_FILES['userfiles']['name'][$x]." was sent successfully</p>"; //Echo "<p>File was named ".$filename."</p>"; }else{ Echo "There was a problem sending file ".$_FILES['userfiles']['name'][$x]."<br>";; } } // close the FTP stream Ftp_close($conn_id); } Else echo"<p>File was not uploaded!</p>"; } } }//end for loop Echo "<p class='back'><a href='upload.php'>«Back</a></p>"; } Echo "</div> </div><!--content-middle end--> <div id='content-bottom'></div> </div><!--layout-content end--> </div><!--layout end--> </body> </html>"; ?> Link to comment https://forums.phpfreaks.com/topic/186519-safari-vs-firefox/#findComment-985057 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.