tpearson Posted November 27, 2007 Share Posted November 27, 2007 ok...ill see if i get a responce here...i have up and running on a windows 2kpro apache (latest) + php (latest) and have phpwebftp working. Everything with this code works great but if i upload a file it get corrupt and downloading the file does the same. need help and im sure this is a easy fix. 1 area that may be the problem is the download tmp folder path...on windows it has to be a certain format and i've tried a few but not 100% sure it im correct. the path i have in config file is "c:/ftpwebclient/tmp" I can paste code iff needed if anyone can assist me.....thanks Quote Link to comment https://forums.phpfreaks.com/topic/79115-upload-files-corrupting/ Share on other sites More sharing options...
MadTechie Posted November 27, 2007 Share Posted November 27, 2007 need code.. please post using code tags (#) Quote Link to comment https://forums.phpfreaks.com/topic/79115-upload-files-corrupting/#findComment-400460 Share on other sites More sharing options...
tpearson Posted November 27, 2007 Author Share Posted November 27, 2007 ok..heres the index.php <?php /* */ include('config.inc.php'); //load configuration $currentVersion = "3.3b"; // Report simple running errors //error_reporting(E_ERROR | E_WARNING | E_PARSE); error_reporting(E_ERROR | E_PARSE); //Procedure for emptying the tmp directory if($clearTemp==true) { if ($handle = opendir($downloadDir)) { while (false !== ($delFile = readdir($handle))) { if($delFile!="." and $delFile!="..") { unlink($downloadDir . $delFile); } } closedir($handle); } } include("include/functions.inc.php"); include("include/ftp.class.php"); session_start(); // Get the POST, GET and SESSION variables (if register_globals=off (PHP4.2.1+)) // It's a bit of a dirty hack but variables are sometimes GET and sometimes POST variables $goPassive=(isset($_POST['goPassive']))?$_POST['goPassive']:$_GET['goPassive']; $mode=(isset($_POST['mode']))?$_POST['mode']:$_GET['mode']; $actionType=(isset($_POST['actionType']))?$_POST['actionType']:$_GET['actionType']; $currentDir=stripSlashes((isset($_POST['currentDir']))?$_POST['currentDir']:$_GET['currentDir']); $file=(isset($_POST['file']))?$_POST['file']:$_GET['file']; $file2=(isset($_POST['file2']))?$_POST['file2']:$_GET['file2']; $permissions=(isset($_POST['permissions']))?$_POST['permissions']:$_GET['permissions']; $directory=(isset($_POST['directory']))?$_POST['directory']:$_GET['directory']; $fileContent=(isset($_POST['fileContent']))?$_POST['fileContent']:$_GET['fileContent']; $file=StripSlashes($file); $file2=StripSlashes($file2); $mode=(isset($mode))?$mode:1; if(isset($_POST['user'])) { // we dont care if we are already logged or not in case user provides // login information. That allows relogging in without explicitly // loging out, eg with the "back" button. if ($editDefaultServer) $_SESSION['server']=$_POST['server']; else $_SESSION['server']=$defaultServer; $_SESSION['user']=$_POST['user']; $_SESSION['password']=$_POST['password']; $_SESSION['language']=$_POST['language']; $_SESSION['port']=$_POST['port']; $_SESSION['passive']=$_POST['passive']; } if ($actionType=="logoff") { unset($_SESSION['server']); unset($_SESSION['user']); unset($_SESSION['password']); unset($_SESSION['port']); unset($_SESSION['passive']); session_destroy(); } $server=$_SESSION['server']; $user=$_SESSION['user']; $password=$_SESSION['password']; $language=$_SESSION['language']; $port=$_SESSION['port']; $passive=$_SESSION['passive']; // If language is not yet set, check the default language or try to get the language from your browser. if($language==""){ if ($defaultLanguage !="") { $language = $defaultLanguage ; } else { $browser_lang = getenv("http_accept_language"); $tmplang = $languages[$browser_lang]; if(file_exists("include/language/" . $tmplang . ".lang.php")) { $language = $tmplang; } else { $language = "english"; } } } //Include Language file include("include/language/" . $language . ".lang.php"); // Selected language if ($server!="") { $ftp = new ftp($server, $port, $user, $password, $passive); $ftp->setMode($mode); $ftp->setCurrentDir($currentDir); // set some default values as defined in config.inc.php $ftp->setResumeDownload($resumeDownload); $ftp->setDownloadDir($downloadDir); if ($ftp->loggedOn) { $msg = $ftp->getCurrentDirectoryShort(); // what to do now ??? if(isset($actionType)) { switch ($actionType) { case "chmod": // Change permissions if($ftp->chmod($permissions, $file)){ print $lblFilePermissionChanged; } else { print $lblCouldNotChangePermissions; } break; case "cd": // Change directory $ftp->cd($file); $msg = $lblndexOf . $ftp->getCurrentDirectoryShort(); break; case "get": // Download file $ftp->download($file) or DIE($lblErrorDownloadingFile); break; case "put": // Upload file $fileObject = $_FILES['file']; if($fileObject['size'] > $maxFileSize) { $msg = "<B>" . $lblFileSizeTooBig . "</B> (max. " . $maxFileSize . " bytes)<P>"; } elseif(!$ftp->upload($fileObject)) { $msg = $lblFileCouldNotBeUploaded; } break; case "deldir"; // Delete directory $ftp->deleteRecursive($file); break; case "delfile"; // Delete file $ftp->deleteFile($file); break; case "rename"; // Rename file if($ftp->rename($file, $file2)) { $msg = $file . " " . $lblRenamedTo . " " . $file2; } else { $msg = $lblCouldNotRename . " " . $file . " " . $lblTo . " " . $file2; } break; case "createdir": // Create a new directory if($ftp->makeDir($file)) { $msg = $file . " " . $lblCreated; } else { $msg = $lblCouldNotCreate . " " . $file; } break; case "edit": //First download the file to the server $ftp->get($file); //Now open the content of the file in an edit window ?> <html> <HEAD> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>NBAS Audits</TITLE> <LINK REL=StyleSheet HREF="style/cm.css" TITLE=Contemporary TYPE="text/css"> <SCRIPT LANGUAGE="JavaScript" SRC="include/script.js"></SCRIPT> </HEAD> <body> <h2>Edit <?php echo $file;?></h2> <FORM METHOD=POST NAME='editFileForm' ACTION="<?php echo $php_self;?>"> <INPUT TYPE='hidden' NAME='actionType' VALUE='saveFile'> <INPUT TYPE='hidden' NAME='currentDir' VALUE='<?php echo $ftp->currentDir;?>'> <INPUT TYPE='hidden' NAME='file' VALUE='<?php echo $file;?>'> <INPUT TYPE='hidden' NAME='mode' VALUE='<?php echo $ftp->mode;?>'> <TEXTAREA NAME="fileContent" ROWS='30' COLS='80'><?php $data = stripslashes(readfile_chucked($ftp->downloadDir . $file));?></TEXTAREA> <br> <INPUT TYPE="submit" value="save"><INPUT TYPE=button OnClick='cancelEditFile();' VALUE="cancel" > </FORM> </body> </html> <?php unlink($ftp->downloadDir . $file); exit; break; case "saveFile": //Write content of fileContent to tempFile $tempFile = "tmpFile.txt"; $fp = fopen($ftp->downloadDir . $tempFile, "w+t"); if ($bytes=!fwrite($fp, stripslashes($fileContent))) { $msg = $lblFileCouldNotBeUploaded; } fclose($fp); //Upload the file to the server if(!$ftp->put($ftp->currentDir . "/" . filePart(StripSlashes($file)),$ftp->downloadDir . $tempFile)) $msg = $lblFileCouldNotBeUploaded; //Delete temporary file unlink($ftp->downloadDir . $tempFile); break; case "getzip": set_time_limit(3000); //for big archives $zipfile = $file . ".zip"; $dir = $ftp->downloadDir.$ftp->user . "/"; // a directory for every user, just in case... header("Content-disposition: attachment; filename=\"$zipfile\""); header("Content-type: application/octetstream"); header("Pragma: "); header("Cache-Control: cache"); header("Expires: 0"); $zipfile = $ftp->downloadDir . $zipfile; //Create temporary diretory mkdir($dir); //Get entire directory and store to temporary directory $ftp->getRecursive($ftp->currentDir, $file); //zip the directory $zip = new ss_zip('',6); $zip->zipDirTree($dir, $dir); $zip->save($zipfile); //send zipfile to the browser $filearray = explode("/",$zipfile); $file = $filearray[sizeof($filearray)-1]; $data = readfile($zipfile); $i=0; while ($data[$i] != "") { echo $data[$i]; $i++; } //Delete zip file unlink($zipfile); //Delete downloaded files from user specific directory deleteRecursive($dir); exit; break; } } ?> <HTML> <HEAD> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>NBAS Audits</TITLE> <LINK REL=StyleSheet HREF="style/cm.css" TITLE=Contemporary TYPE="text/css"> <SCRIPT LANGUAGE="JavaScript" SRC="include/script.js"></SCRIPT> </HEAD> <BODY> <TABLE CELLPADDING=0 CELLSPACING=0 HEIGHT="100%"> <TR><TD> <TABLE BORDER=0 CELLPADDING=2 CELLSPACING=0 WIDTH='100%'> <TR> <TD CLASS=titlebar COLSPAN=3> <B>NBAS Audits</B> </TD> </TR> <TR> <TD CLASS=menu> <?php $newMode=($ftp->mode==1)?0:1; ?> <?php if($ftp->loggedOn) { ?> <TABLE CELLPADDING=0 CELLSPACING=0><TR> <TD VALIGN=CENTER> <A HREF='javascript:submitForm("cd","..")'><IMG SRC="img/parent.gif" HEIGHT=24 WIDTH=24 ALIGN=TOP BORDER=0></A></TD> <TD VALIGN=CENTER><nobr><A HREF='javascript:submitForm("cd","..")'> <?php echo $lblUp;?></A> </nobr></TD> <TD VALIGN=CENTER> <A CLASS=menu HREF="javascript:changeMode('<?php echo $newMode;?>')"><IMG SRC="img/mode.gif" HEIGHT=24 BORDER=0 ALIGN=CENTER></A></TD> <TD VALIGN=CENTER><nobr><A CLASS=menu HREF="javascript:changeMode('<?php echo $newMode;?>')"> <?php echo $lblChangeMode;?></A> </nobr></TD> <TD VALIGN=CENTER> <A CLASS=menu HREF="javascript:logOff()"><IMG SRC="img/logoff.gif" HEIGHT=24 BORDER=0 ALIGN=CENTER></A></TD> <TD VALIGN=CENTER><nobr><A CLASS=menu HREF="javascript:logOff()"> <?php echo $lblLogOff;?></A> </nobr></TD> <TD COLSPAN=6 VALIGN=TOP class=statusbar width="100%" VALIGN=CENTER ALIGN=RIGHT> <?php echo directoryPath($ftp->currentDir, $server);?> </TD> </TR> </TABLE> <?php } else { ?> <TABLE CELLPADDING=0 CELLSPACING=0><TR> <TD VALIGN=CENTER> <A CLASS=menu HREF="javascript:logOff()"><IMG SRC="img/logoff.gif" HEIGHT=24 BORDER=0 ALIGN=CENTER></A> </TD> <TD VALIGN=CENTER> <A CLASS=menu HREF="javascript:logOff()"><?php echo $lblRetry;?></A> </TD> </TR></TABLE> <?php } ?> </TD> </FORM> </TR> </TABLE> </TD></TR> <TR><TD HEIGHT="100%"> <FORM NAME="actionform" METHOD=POST ACTION='<?php echo $PHP_SELF;?>'> <INPUT TYPE='hidden' NAME='actionType' VALUE=''> <INPUT TYPE='hidden' NAME='delaction' VALUE=''> <INPUT TYPE='hidden' NAME='currentDir' VALUE='<?php echo $ftp->currentDir;?>'> <INPUT TYPE='hidden' NAME='file' VALUE=''> <INPUT TYPE='hidden' NAME='file2' VALUE=''> <INPUT TYPE='hidden' NAME='extension' VALUE=''> <INPUT TYPE='hidden' NAME='permissions' VALUE=''> <INPUT TYPE='hidden' NAME='mode' VALUE='<?php echo $ftp->mode;?>' STYLE='border: none; background-color: #EFEFEF;'> </FORM> <HR> <TABLE HEIGHT="100%"> <TR> <TD class=leftmenu VALIGN=TOP width=210> <DIV ALIGN=CENTER> <BR> <!-- File and folder --> <TABLE CELLPADDING=0 CELLSPACING=0 class=item> <TR> <TD VALIGN=TOP class=itemhead> <B><?php echo $lblFileTasks;?></B> </TD> </FORM> </TR> <TR> <TD VALIGN=TOP class=leftmenuitem> <DIV id="fileactions" style='display:none;'> <TABLE> <!-- Delete File --> <TR> <TD VALIGN=CENTER><IMG SRC="img/menu_delete.gif"></TD> <TD VALIGN=CENTER> <A HREF='javascript:deleteFile()' class=leftmenulink><?php echo $lblDeleteFile;?></A> </TD> </TR> <TR> <TD VALIGN=CENTER><IMG SRC="img/zip.gif"></TD> <TD VALIGN=CENTER> <A HREF='javascript:zipFile()' class=leftmenulink><?php echo "Zip & download";?></A> </TD> </TR> <TR> <TD VALIGN=CENTER><IMG SRC="img/menu_edit.gif"></TD> <TD VALIGN=CENTER> <A HREF='javascript:editFile()' class=leftmenulink><?php echo $lblEditFile;?></A> </TD> </TR> <TR> <TD VALIGN=top><IMG SRC="img/menu_rename.gif"></TD> <TD VALIGN=top> <A HREF='javascript:setNewFileName("<?php echo $myDir["name"];?>")' class=leftmenulink><?php echo $lblRename;?></A> <!-- Rename file --> <DIV ID='renameFileEntry' style='display:none;'> <FORM NAME=renameFile> <TABLE CELLSPACING=0 class=lined align=center> <TR> <TD class=tinyblue> <B><?php echo $lblNewName;?></B><BR> <INPUT TYPE="text" NAME="newName" value=""></TD> </TR> </TABLE> <BR> <DIV ALIGN=CENTER><INPUT TYPE=button OnClick='renameItem();' VALUE='<?php echo $lblRename;?>'></DIV> </FORM> <BR> </DIV> </TD> </TR> <TR> <TD VALIGN=top><IMG SRC="img/menu_settings.gif"></TD> <TD VALIGN=top> <A HREF='javascript:;' OnClick='setPermissions()' class=leftmenulink><?php echo $lblSetPermissions;?></A> <!-- Change permissions --> <DIV ID='setPermissions' style='display:none;'> <FORM NAME=permissions> <TABLE CELLSPACING=0 class=lined align=center> <TR> <TD class=tinyblue ALIGN=CENTER><B><?php echo $lblOwner;?></B></TD> <TD class=tiny ALIGN=CENTER><B><?php echo $lblGroup;?></B></TD> <TD class=tinywhite ALIGN=CENTER><B><?php echo $lblPublic;?></B></TD> </TR> <TR> <TD class=tinyblue><INPUT TYPE="checkbox" NAME="iOr"> <?php echo $lblRead;?></TD> <TD class=tiny><INPUT TYPE="checkbox" NAME="iGr"> <?php echo $lblRead;?></TD> <TD class=tinywhite><INPUT TYPE="checkbox" NAME="iPr"> <?php echo $lblRead;?></TD> </TR> <TR> <TD class=tinyblue><INPUT TYPE="checkbox" NAME="iOw"> <?php echo $lblWrite;?></TD> <TD class=tiny><INPUT TYPE="checkbox" NAME="iGw"> <?php echo $lblWrite;?></TD> <TD class=tinywhite><INPUT TYPE="checkbox" NAME="iPw"> <?php echo $lblWrite;?></TD> </TR> <TR> <TD class=tinyblue><INPUT TYPE="checkbox" NAME="iOx"> <?php echo $lblExecute;?></TD> <TD class=tiny><INPUT TYPE="checkbox" NAME="iGx"> <?php echo $lblExecute;?></TD> <TD class=tinywhite><INPUT TYPE="checkbox" NAME="iPx"> <?php echo $lblExecute;?></TD> </TR> </TABLE> <BR> <DIV ALIGN=CENTER><INPUT TYPE=button OnClick='changePermissions()' VALUE='<?php echo $lblSetPermissions;?>'></DIV> </FORM> <BR> </DIV> </TD> </TR> </TABLE> </DIV> <!-- Standaard actions --> <TABLE> <TR> <TD VALIGN=top><IMG SRC="img/upload.gif" BORDER="0" ALT=""></TD> <TD VALIGN=top> <A HREF="JavaScript:toggle('uploadform');" class=leftmenulink><?php echo $lblUploadFile;?></A> <FORM id="uploadform" style='display:none;' NAME='putForm' ENCTYPE="multipart/form-data" METHOD=POST ACTION="<?php echo $PHP_SELF;?>"> <INPUT TYPE="hidden" NAME="actionType" VALUE="put"> <INPUT TYPE='hidden' NAME='currentDir' VALUE='<?php echo $ftp->currentDir;?>'> <INPUT TYPE='hidden' NAME='mode' VALUE='<?php echo $ftp->mode;?>'> <INPUT TYPE="file" NAME="file" size=8 STYLE="width:10px; font-size:7pt;" onChange='document.uploadform.submit();'><BR> <INPUT TYPE="SUBMIT" VALUE="UPLOAD" STYLE='width=150px; font-size:7pt;'> </FORM> </TD> </TR> <TR> <TD VALIGN=top><IMG SRC="img/createdir.gif" BORDER="0" ALT=""></TD> <TD VALIGN=top> <A HREF="JavaScript:toggle('createform');" class=leftmenulink><?php echo $lblCreateDirectory;?></A> <FORM id="createform" style='display:none;' METHOD=POST NAME='dirinput' ACTION="<?php echo $PHP_SELF;?>"> <INPUT TYPE="text" NAME="directory" VALUE="" STYLE="width:100px; font-size:7pt;"> <INPUT TYPE="BUTTON" VALUE="OK" OnClick='javascript:createDirectory(dirinput.directory.value)' STYLE="width:40px; font-size:7pt;"> </FORM> </TD> </TR> <TR> <TD VALIGN=top><IMG SRC="img/gotodir.gif" BORDER="0" ALT=""></TD> <TD VALIGN=top> <A HREF="JavaScript:toggle('gotoform');" class=leftmenulink><?php echo $lblGoToDirectory;?></A> <FORM id="gotoform" style='display:none;' NAME='cdDirect' METHOD=POST ACTION='<?php echo $PHP_SELF;?>'> <INPUT TYPE='hidden' NAME='actionType' VALUE='cd'> <INPUT TYPE='hidden' NAME='currentDir' VALUE='<?php echo $ftp->currentDir;?>'> <INPUT TYPE="text" NAME="file" VALUE="" STYLE="width:100px; font-size:7pt;"> <INPUT TYPE="SUBMIT" VALUE="OK" STYLE="width:40px; font-size:7pt;"> </FORM> </TD> </TR> </TABLE> </TD> </TR> </TABLE> <P> <!-- Details --> <TABLE CELLPADDING=0 CELLSPACING=0 class=item> <TR> <TD VALIGN=TOP class=itemhead> <B><?php echo $lblDetails;?></B> </TD> </FORM> </TR> <TR> <TD VALIGN=TOP class=leftmenuitem style='color:black' > <BR> <B><?php echo $msg;?></B> <P> <?php echo ($ftp->loggedOn)?"$lblConnectedTo $server:$port ($ftp->systype)":$lblNotConnected;?> <P> <?php echo $lblTransferMode;?> :<?php echo $ftp->mode==1?$lblBinaryMode:$lblASCIIMode;?> <BR><BR> </TD> </TR> </TABLE> </DIV> </TD> <TD VALIGN=TOP> <P> <TABLE WIDTH="650" CELLSPACING=0 CELLPADDING=0 onClick='resetEntries()'> <TR> <TD COLSPAN=2 class=listhead><?php echo $lblName;?></TD> <TD class=listhead><IMG SRC="img/listheaddiv.gif"></TD> <TD class=listhead align=right><?php echo $lblSize;?> </TD> <TD class=listhead><IMG SRC="img/listheaddiv.gif"></TD> <TD class=listhead><?php echo $lblFileType;?> </TD> <TD class=listhead><IMG SRC="img/listheaddiv.gif"></TD> <TD class=listhead><?php echo $lblDate;?></TD> <TD class=listhead><IMG SRC="img/listheaddiv.gif"></TD> <TD class=listhead><?php echo $lblPermissions;?></TD> <TD class=listhead><IMG SRC="img/listheaddiv.gif"></TD> <TD class=listhead><?php echo $lblOwner;?></TD> <TD class=listhead><IMG SRC="img/listheaddiv.gif"></TD> <TD class=listhead><?php echo $lblGroup;?></TD> <TD class=listhead><IMG SRC="img/listheaddiv.gif"></TD> </TR> <?php $list = $ftp->ftpRawList(); if (is_array($list)) { // Directories $counter=0; foreach($list as $myDir) { if ($myDir["is_dir"]==1) { $fileAction = "cd"; $fileName = $myDir["name"]; $fileSize=""; $delAction = "deldir"; $fileType['description'] = 'File Folder'; $fileType['imgfilename'] = 'folder.gif'; } if ($myDir["is_link"]==1) { $fileAction = "cd"; $fileName = $myDir["target"]; $fileSize=""; $delAction = "delfile"; $fileType['description'] = 'Symbolic Link'; $fileType['imgfilename'] = 'link.gif'; } if ($myDir["is_link"]!=1 && $myDir["is_dir"]!=1) { $fileType = fileDescription($myDir["name"]); $fileAction = "get"; $fileName = $myDir["name"]; $image = "file.gif"; if($myDir["size"]<1024) { $fileSize= $myDir["size"] . " bytes "; $fileSize=number_format($myDir["size"], 0, ',', '.') . " bytes"; } else { if($myDir["size"]<1073741824) { $fileSize=number_format($myDir["size"]/1024, 0, ',', '.') . " KB"; } else { $fileSize=number_format($myDir["size"]/1048576, 0, ',', '.') . " MB"; } } $delAction = "delfile"; } ?> <TR> <TD class=filenamecol width=20><A HREF='javascript:selectEntry("<?php echo $fileAction;?>","<?php echo $fileName;?>","filename<?php echo $counter;?>","<?php echo $myDir["perms"];?>","<?php echo $delAction;?>")' ondblclick='submitForm("<?php echo $fileAction;?>","<?php echo $fileName;?>")'><IMG SRC="img/<?php echo $fileType['imgfilename'];?>" ALIGN=TOP BORDER=0></A></TD> <TD class=filenamecol><span id='filename<?php echo $counter;?>'><A HREF='javascript:selectEntry("<?php echo $fileAction;?>","<?php echo $fileName;?>","filename<?php echo $counter;?>","<?php echo $myDir["perms"];?>","<?php echo $delAction;?>")' ondblclick='submitForm("<?php echo $fileAction;?>","<?php echo $fileName;?>")'><?php echo $fileName;?></A></span></TD> <TD> </TD> <TD ALIGN=RIGHT><?php echo $fileSize;?></TD> <TD> </TD> <TD ALIGN=left><?php echo $fileType['description'];?></TD> <TD> </TD> <TD><?php echo $myDir["date"];?></TD> <TD> </TD> <TD><?php echo $myDir["perms"];?></TD> <TD> </TD> <TD><?php echo $myDir["user"];?></TD> <TD> </TD> <TD><?php echo $myDir["group"];?></TD> <TD> </TD> </TR> <?php $counter++; } } else { ?> <TR> <TD colspan=14><BR><B><?php echo $lblDirectoryEmpty;?>...</B></TD> </TR> <?php } print " </TABLE></TD></TR></TABLE>"; } else { if(!isset($msg)) { $msg = "$lblCouldNotConnectToServer $server:$port $lblWithUser $user<P><A HREF='" . $_SERVER["PHP_SELF"] . "'>$lblTryAgain</A>"; unset($_SESSION['server']); unset($_SESSION['user']); unset($_SESSION['password']); unset($_SESSION['port']); session_destroy(); } ?> </TD></TR></TABLE> <HTML> <HEAD> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>NBAS Audits</TITLE> <LINK REL=StyleSheet HREF="style/cm.css" TITLE=Contemporary TYPE="text/css"> <SCRIPT LANGUAGE="JavaScript" SRC="include/script.js"></SCRIPT> </HEAD> <BODY> <?php print $msg; } } else // Still need to logon... { ?> <HTML> <HEAD> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>NBAS Audits</TITLE> <LINK REL=StyleSheet HREF="style/cm.css" TITLE=Contemporary TYPE="text/css"> <SCRIPT LANGUAGE="JavaScript" SRC="include/script.js"></SCRIPT> </HEAD> <BODY> <table align="center"> <tr> <TD COLSPAN=3><IMG SRC="img/logo.jpg" HEIGHT=140 width="329"></TD> </tr> </table> <FORM NAME=login action='<?php echo $_SERVER['PHP_SELF'];?>' METHOD=POST> <TABLE align="center" class=login cellpadding=3> <TR> <TD COLSPAN=3><B> <?php echo $lblLogIn;?></B></TD> </TR> <TR> <TD COLSPAN=3><IMG SRC="img/1px.gif" HEIGHT=60></TD> </TR> <TR> <TD COLSPAN=3> <?php echo $lblConnectToFTPServer;?></TD> </TR> <TR> <TD VALIGN=TOP> <?php echo $lblServer;?></TD> <TD VALIGN=TOP> <?php if($defaultServer == "") { print "<INPUT TYPE=TEXT NAME=server SIZE=15> "; } else { $inputType=($editDefaultServer==true)?"TEXT":"HIDDEN"; print "<INPUT TYPE=" . $inputType . " NAME=server VALUE=" . $defaultServer . ">"; if($editDefaultServer==false) { print "<B>" . $defaultServer . "</B> "; } } ?> </TD> <TD VALIGN=TOP> <TABLE CELLSPACING=0> <TR> <TD><?php echo $lblPort;?></TD> <TD><INPUT TYPE=TEXT NAME=port SIZE=3 VALUE=21></TD> </TR> <TR> <TD><?php echo $lblPasive;?></TD> <TD><INPUT TYPE="checkbox" NAME="goPassive"></TD> </TR> </TABLE> </TD> </TR> <TR> <TD> <?php echo $lblUser;?></TD> <TD> <INPUT TYPE=TEXT NAME=user SIZE=18> </TD> <TD> </TD> </TR> <TR> <TD> <?php echo $lblPassword;?></TD> <TD><INPUT TYPE=PASSWORD NAME=password SIZE=18></TD> <TD><INPUT TYPE=SUBMIT VALUE="Log on"></TD> </TR> <?php if($defaultLanguage == "") { ?> <TR> <TD> <?php echo $lblLanguage;?></TD> <TD colspan=2> <?php ?> <SELECT NAME="language"> <?php if ($handle = opendir('include/language/')) { //Read file in directory and store them in an Array while (false !== ($file = readdir($handle))) { $fileArray[$file] = $file; } //Sort the array ksort($fileArray); foreach($fileArray as $file) { if ($file != "." && $file != ".." ) { $file=str_replace(".lang.php","",$file); $counter=0; foreach($languages as $thislang) { if($thislang==$file) { $counter++; } } if($counter>0) { $langName=strtoupper(substr($file,0,1)) . substr($file,1); ?> <OPTION VALUE="<?php echo $file;?>" <?php echo ($language==$file)?"selected":"";?>><?php echo $langName;?></OPTION> <?php } } } closedir($handle); } ?> </SELECT> </TR> <?php } // End default server ?> <TR> <TD COLSPAN=2><IMG SRC="img/1px.gif" HEIGHT=5></TD> </TR> </TABLE> <TABLE WIDTH=328> <TR> <TD COLSPAN=2 VALIGN=TOP class=leftmenuitem> <P> </TD> </TR> <TR> <TD ALIGN=LEFT> </TD> <TD ALIGN=RIGHT> </TD> </TR> </TABLE> </FORM> <?php } ?> <P> </BODY> </HTML> Quote Link to comment https://forums.phpfreaks.com/topic/79115-upload-files-corrupting/#findComment-400480 Share on other sites More sharing options...
tpearson Posted November 27, 2007 Author Share Posted November 27, 2007 the code is from phpftpweb....and the site i have it one is https://ftp.nbasaudits.com any help will be greatly appreicated!! Quote Link to comment https://forums.phpfreaks.com/topic/79115-upload-files-corrupting/#findComment-400483 Share on other sites More sharing options...
thefollower Posted November 27, 2007 Share Posted November 27, 2007 need code.. please post using code tags (#) using code tags (#) Quote Link to comment https://forums.phpfreaks.com/topic/79115-upload-files-corrupting/#findComment-400484 Share on other sites More sharing options...
tpearson Posted November 27, 2007 Author Share Posted November 27, 2007 <?php /* */ include('config.inc.php'); //load configuration $currentVersion = "3.3b"; // Report simple running errors //error_reporting(E_ERROR | E_WARNING | E_PARSE); error_reporting(E_ERROR | E_PARSE); //Procedure for emptying the tmp directory if($clearTemp==true) { if ($handle = opendir($downloadDir)) { while (false !== ($delFile = readdir($handle))) { if($delFile!="." and $delFile!="..") { unlink($downloadDir . $delFile); } } closedir($handle); } } include("include/functions.inc.php"); include("include/ftp.class.php"); session_start(); // Get the POST, GET and SESSION variables (if register_globals=off (PHP4.2.1+)) // It's a bit of a dirty hack but variables are sometimes GET and sometimes POST variables $goPassive=(isset($_POST['goPassive']))?$_POST['goPassive']:$_GET['goPassive']; $mode=(isset($_POST['mode']))?$_POST['mode']:$_GET['mode']; $actionType=(isset($_POST['actionType']))?$_POST['actionType']:$_GET['actionType']; $currentDir=stripSlashes((isset($_POST['currentDir']))?$_POST['currentDir']:$_GET['currentDir']); $file=(isset($_POST['file']))?$_POST['file']:$_GET['file']; $file2=(isset($_POST['file2']))?$_POST['file2']:$_GET['file2']; $permissions=(isset($_POST['permissions']))?$_POST['permissions']:$_GET['permissions']; $directory=(isset($_POST['directory']))?$_POST['directory']:$_GET['directory']; $fileContent=(isset($_POST['fileContent']))?$_POST['fileContent']:$_GET['fileContent']; $file=StripSlashes($file); $file2=StripSlashes($file2); $mode=(isset($mode))?$mode:1; if(isset($_POST['user'])) { // we dont care if we are already logged or not in case user provides // login information. That allows relogging in without explicitly // loging out, eg with the "back" button. if ($editDefaultServer) $_SESSION['server']=$_POST['server']; else $_SESSION['server']=$defaultServer; $_SESSION['user']=$_POST['user']; $_SESSION['password']=$_POST['password']; $_SESSION['language']=$_POST['language']; $_SESSION['port']=$_POST['port']; $_SESSION['passive']=$_POST['passive']; } if ($actionType=="logoff") { unset($_SESSION['server']); unset($_SESSION['user']); unset($_SESSION['password']); unset($_SESSION['port']); unset($_SESSION['passive']); session_destroy(); } $server=$_SESSION['server']; $user=$_SESSION['user']; $password=$_SESSION['password']; $language=$_SESSION['language']; $port=$_SESSION['port']; $passive=$_SESSION['passive']; // If language is not yet set, check the default language or try to get the language from your browser. if($language==""){ if ($defaultLanguage !="") { $language = $defaultLanguage ; } else { $browser_lang = getenv("http_accept_language"); $tmplang = $languages[$browser_lang]; if(file_exists("include/language/" . $tmplang . ".lang.php")) { $language = $tmplang; } else { $language = "english"; } } } //Include Language file include("include/language/" . $language . ".lang.php"); // Selected language if ($server!="") { $ftp = new ftp($server, $port, $user, $password, $passive); $ftp->setMode($mode); $ftp->setCurrentDir($currentDir); // set some default values as defined in config.inc.php $ftp->setResumeDownload($resumeDownload); $ftp->setDownloadDir($downloadDir); if ($ftp->loggedOn) { $msg = $ftp->getCurrentDirectoryShort(); // what to do now ??? if(isset($actionType)) { switch ($actionType) { case "chmod": // Change permissions if($ftp->chmod($permissions, $file)){ print $lblFilePermissionChanged; } else { print $lblCouldNotChangePermissions; } break; case "cd": // Change directory $ftp->cd($file); $msg = $lblndexOf . $ftp->getCurrentDirectoryShort(); break; case "get": // Download file $ftp->download($file) or DIE($lblErrorDownloadingFile); break; case "put": // Upload file $fileObject = $_FILES['file']; if($fileObject['size'] > $maxFileSize) { $msg = "<B>" . $lblFileSizeTooBig . "</B> (max. " . $maxFileSize . " bytes)<P>"; } elseif(!$ftp->upload($fileObject)) { $msg = $lblFileCouldNotBeUploaded; } break; case "deldir"; // Delete directory $ftp->deleteRecursive($file); break; case "delfile"; // Delete file $ftp->deleteFile($file); break; case "rename"; // Rename file if($ftp->rename($file, $file2)) { $msg = $file . " " . $lblRenamedTo . " " . $file2; } else { $msg = $lblCouldNotRename . " " . $file . " " . $lblTo . " " . $file2; } break; case "createdir": // Create a new directory if($ftp->makeDir($file)) { $msg = $file . " " . $lblCreated; } else { $msg = $lblCouldNotCreate . " " . $file; } break; case "edit": //First download the file to the server $ftp->get($file); //Now open the content of the file in an edit window ?> <html> <HEAD> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>NBAS Audits</TITLE> <LINK REL=StyleSheet HREF="style/cm.css" TITLE=Contemporary TYPE="text/css"> <SCRIPT LANGUAGE="JavaScript" SRC="include/script.js"></SCRIPT> </HEAD> <body> <h2>Edit <?php echo $file;?></h2> <FORM METHOD=POST NAME='editFileForm' ACTION="<?php echo $php_self;?>"> <INPUT TYPE='hidden' NAME='actionType' VALUE='saveFile'> <INPUT TYPE='hidden' NAME='currentDir' VALUE='<?php echo $ftp->currentDir;?>'> <INPUT TYPE='hidden' NAME='file' VALUE='<?php echo $file;?>'> <INPUT TYPE='hidden' NAME='mode' VALUE='<?php echo $ftp->mode;?>'> <TEXTAREA NAME="fileContent" ROWS='30' COLS='80'><?php $data = stripslashes(readfile_chucked($ftp->downloadDir . $file));?></TEXTAREA> <br> <INPUT TYPE="submit" value="save"><INPUT TYPE=button OnClick='cancelEditFile();' VALUE="cancel" > </FORM> </body> </html> <?php unlink($ftp->downloadDir . $file); exit; break; case "saveFile": //Write content of fileContent to tempFile $tempFile = "tmpFile.txt"; $fp = fopen($ftp->downloadDir . $tempFile, "w+t"); if ($bytes=!fwrite($fp, stripslashes($fileContent))) { $msg = $lblFileCouldNotBeUploaded; } fclose($fp); //Upload the file to the server if(!$ftp->put($ftp->currentDir . "/" . filePart(StripSlashes($file)),$ftp->downloadDir . $tempFile)) $msg = $lblFileCouldNotBeUploaded; //Delete temporary file unlink($ftp->downloadDir . $tempFile); break; case "getzip": set_time_limit(3000); //for big archives $zipfile = $file . ".zip"; $dir = $ftp->downloadDir.$ftp->user . "/"; // a directory for every user, just in case... header("Content-disposition: attachment; filename=\"$zipfile\""); header("Content-type: application/octetstream"); header("Pragma: "); header("Cache-Control: cache"); header("Expires: 0"); $zipfile = $ftp->downloadDir . $zipfile; //Create temporary diretory mkdir($dir); //Get entire directory and store to temporary directory $ftp->getRecursive($ftp->currentDir, $file); //zip the directory $zip = new ss_zip('',6); $zip->zipDirTree($dir, $dir); $zip->save($zipfile); //send zipfile to the browser $filearray = explode("/",$zipfile); $file = $filearray[sizeof($filearray)-1]; $data = readfile($zipfile); $i=0; while ($data[$i] != "") { echo $data[$i]; $i++; } //Delete zip file unlink($zipfile); //Delete downloaded files from user specific directory deleteRecursive($dir); exit; break; } } ?> <HTML> <HEAD> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>NBAS Audits</TITLE> <LINK REL=StyleSheet HREF="style/cm.css" TITLE=Contemporary TYPE="text/css"> <SCRIPT LANGUAGE="JavaScript" SRC="include/script.js"></SCRIPT> </HEAD> <BODY> <TABLE CELLPADDING=0 CELLSPACING=0 HEIGHT="100%"> <TR><TD> <TABLE BORDER=0 CELLPADDING=2 CELLSPACING=0 WIDTH='100%'> <TR> <TD CLASS=titlebar COLSPAN=3> <B>NBAS Audits</B> </TD> </TR> <TR> <TD CLASS=menu> <?php $newMode=($ftp->mode==1)?0:1; ?> <?php if($ftp->loggedOn) { ?> <TABLE CELLPADDING=0 CELLSPACING=0><TR> <TD VALIGN=CENTER> <A HREF='javascript:submitForm("cd","..")'><IMG SRC="img/parent.gif" HEIGHT=24 WIDTH=24 ALIGN=TOP BORDER=0></A></TD> <TD VALIGN=CENTER><nobr><A HREF='javascript:submitForm("cd","..")'> <?php echo $lblUp;?></A> </nobr></TD> <TD VALIGN=CENTER> <A CLASS=menu HREF="javascript:changeMode('<?php echo $newMode;?>')"><IMG SRC="img/mode.gif" HEIGHT=24 BORDER=0 ALIGN=CENTER></A></TD> <TD VALIGN=CENTER><nobr><A CLASS=menu HREF="javascript:changeMode('<?php echo $newMode;?>')"> <?php echo $lblChangeMode;?></A> </nobr></TD> <TD VALIGN=CENTER> <A CLASS=menu HREF="javascript:logOff()"><IMG SRC="img/logoff.gif" HEIGHT=24 BORDER=0 ALIGN=CENTER></A></TD> <TD VALIGN=CENTER><nobr><A CLASS=menu HREF="javascript:logOff()"> <?php echo $lblLogOff;?></A> </nobr></TD> <TD COLSPAN=6 VALIGN=TOP class=statusbar width="100%" VALIGN=CENTER ALIGN=RIGHT> <?php echo directoryPath($ftp->currentDir, $server);?> </TD> </TR> </TABLE> <?php } else { ?> <TABLE CELLPADDING=0 CELLSPACING=0><TR> <TD VALIGN=CENTER> <A CLASS=menu HREF="javascript:logOff()"><IMG SRC="img/logoff.gif" HEIGHT=24 BORDER=0 ALIGN=CENTER></A> </TD> <TD VALIGN=CENTER> <A CLASS=menu HREF="javascript:logOff()"><?php echo $lblRetry;?></A> </TD> </TR></TABLE> <?php } ?> </TD> </FORM> </TR> </TABLE> </TD></TR> <TR><TD HEIGHT="100%"> <FORM NAME="actionform" METHOD=POST ACTION='<?php echo $PHP_SELF;?>'> <INPUT TYPE='hidden' NAME='actionType' VALUE=''> <INPUT TYPE='hidden' NAME='delaction' VALUE=''> <INPUT TYPE='hidden' NAME='currentDir' VALUE='<?php echo $ftp->currentDir;?>'> <INPUT TYPE='hidden' NAME='file' VALUE=''> <INPUT TYPE='hidden' NAME='file2' VALUE=''> <INPUT TYPE='hidden' NAME='extension' VALUE=''> <INPUT TYPE='hidden' NAME='permissions' VALUE=''> <INPUT TYPE='hidden' NAME='mode' VALUE='<?php echo $ftp->mode;?>' STYLE='border: none; background-color: #EFEFEF;'> </FORM> <HR> <TABLE HEIGHT="100%"> <TR> <TD class=leftmenu VALIGN=TOP width=210> <DIV ALIGN=CENTER> <BR> <!-- File and folder --> <TABLE CELLPADDING=0 CELLSPACING=0 class=item> <TR> <TD VALIGN=TOP class=itemhead> <B><?php echo $lblFileTasks;?></B> </TD> </FORM> </TR> <TR> <TD VALIGN=TOP class=leftmenuitem> <DIV id="fileactions" style='display:none;'> <TABLE> <!-- Delete File --> <TR> <TD VALIGN=CENTER><IMG SRC="img/menu_delete.gif"></TD> <TD VALIGN=CENTER> <A HREF='javascript:deleteFile()' class=leftmenulink><?php echo $lblDeleteFile;?></A> </TD> </TR> <TR> <TD VALIGN=CENTER><IMG SRC="img/zip.gif"></TD> <TD VALIGN=CENTER> <A HREF='javascript:zipFile()' class=leftmenulink><?php echo "Zip & download";?></A> </TD> </TR> <TR> <TD VALIGN=CENTER><IMG SRC="img/menu_edit.gif"></TD> <TD VALIGN=CENTER> <A HREF='javascript:editFile()' class=leftmenulink><?php echo $lblEditFile;?></A> </TD> </TR> <TR> <TD VALIGN=top><IMG SRC="img/menu_rename.gif"></TD> <TD VALIGN=top> <A HREF='javascript:setNewFileName("<?php echo $myDir["name"];?>")' class=leftmenulink><?php echo $lblRename;?></A> <!-- Rename file --> <DIV ID='renameFileEntry' style='display:none;'> <FORM NAME=renameFile> <TABLE CELLSPACING=0 class=lined align=center> <TR> <TD class=tinyblue> <B><?php echo $lblNewName;?></B><BR> <INPUT TYPE="text" NAME="newName" value=""></TD> </TR> </TABLE> <BR> <DIV ALIGN=CENTER><INPUT TYPE=button OnClick='renameItem();' VALUE='<?php echo $lblRename;?>'></DIV> </FORM> <BR> </DIV> </TD> </TR> <TR> <TD VALIGN=top><IMG SRC="img/menu_settings.gif"></TD> <TD VALIGN=top> <A HREF='javascript:;' OnClick='setPermissions()' class=leftmenulink><?php echo $lblSetPermissions;?></A> <!-- Change permissions --> <DIV ID='setPermissions' style='display:none;'> <FORM NAME=permissions> <TABLE CELLSPACING=0 class=lined align=center> <TR> <TD class=tinyblue ALIGN=CENTER><B><?php echo $lblOwner;?></B></TD> <TD class=tiny ALIGN=CENTER><B><?php echo $lblGroup;?></B></TD> <TD class=tinywhite ALIGN=CENTER><B><?php echo $lblPublic;?></B></TD> </TR> <TR> <TD class=tinyblue><INPUT TYPE="checkbox" NAME="iOr"> <?php echo $lblRead;?></TD> <TD class=tiny><INPUT TYPE="checkbox" NAME="iGr"> <?php echo $lblRead;?></TD> <TD class=tinywhite><INPUT TYPE="checkbox" NAME="iPr"> <?php echo $lblRead;?></TD> </TR> <TR> <TD class=tinyblue><INPUT TYPE="checkbox" NAME="iOw"> <?php echo $lblWrite;?></TD> <TD class=tiny><INPUT TYPE="checkbox" NAME="iGw"> <?php echo $lblWrite;?></TD> <TD class=tinywhite><INPUT TYPE="checkbox" NAME="iPw"> <?php echo $lblWrite;?></TD> </TR> <TR> <TD class=tinyblue><INPUT TYPE="checkbox" NAME="iOx"> <?php echo $lblExecute;?></TD> <TD class=tiny><INPUT TYPE="checkbox" NAME="iGx"> <?php echo $lblExecute;?></TD> <TD class=tinywhite><INPUT TYPE="checkbox" NAME="iPx"> <?php echo $lblExecute;?></TD> </TR> </TABLE> <BR> <DIV ALIGN=CENTER><INPUT TYPE=button OnClick='changePermissions()' VALUE='<?php echo $lblSetPermissions;?>'></DIV> </FORM> <BR> </DIV> </TD> </TR> </TABLE> </DIV> <!-- Standaard actions --> <TABLE> <TR> <TD VALIGN=top><IMG SRC="img/upload.gif" BORDER="0" ALT=""></TD> <TD VALIGN=top> <A HREF="JavaScript:toggle('uploadform');" class=leftmenulink><?php echo $lblUploadFile;?></A> <FORM id="uploadform" style='display:none;' NAME='putForm' ENCTYPE="multipart/form-data" METHOD=POST ACTION="<?php echo $PHP_SELF;?>"> <INPUT TYPE="hidden" NAME="actionType" VALUE="put"> <INPUT TYPE='hidden' NAME='currentDir' VALUE='<?php echo $ftp->currentDir;?>'> <INPUT TYPE='hidden' NAME='mode' VALUE='<?php echo $ftp->mode;?>'> <INPUT TYPE="file" NAME="file" size=8 STYLE="width:10px; font-size:7pt;" onChange='document.uploadform.submit();'><BR> <INPUT TYPE="SUBMIT" VALUE="UPLOAD" STYLE='width=150px; font-size:7pt;'> </FORM> </TD> </TR> <TR> <TD VALIGN=top><IMG SRC="img/createdir.gif" BORDER="0" ALT=""></TD> <TD VALIGN=top> <A HREF="JavaScript:toggle('createform');" class=leftmenulink><?php echo $lblCreateDirectory;?></A> <FORM id="createform" style='display:none;' METHOD=POST NAME='dirinput' ACTION="<?php echo $PHP_SELF;?>"> <INPUT TYPE="text" NAME="directory" VALUE="" STYLE="width:100px; font-size:7pt;"> <INPUT TYPE="BUTTON" VALUE="OK" OnClick='javascript:createDirectory(dirinput.directory.value)' STYLE="width:40px; font-size:7pt;"> </FORM> </TD> </TR> <TR> <TD VALIGN=top><IMG SRC="img/gotodir.gif" BORDER="0" ALT=""></TD> <TD VALIGN=top> <A HREF="JavaScript:toggle('gotoform');" class=leftmenulink><?php echo $lblGoToDirectory;?></A> <FORM id="gotoform" style='display:none;' NAME='cdDirect' METHOD=POST ACTION='<?php echo $PHP_SELF;?>'> <INPUT TYPE='hidden' NAME='actionType' VALUE='cd'> <INPUT TYPE='hidden' NAME='currentDir' VALUE='<?php echo $ftp->currentDir;?>'> <INPUT TYPE="text" NAME="file" VALUE="" STYLE="width:100px; font-size:7pt;"> <INPUT TYPE="SUBMIT" VALUE="OK" STYLE="width:40px; font-size:7pt;"> </FORM> </TD> </TR> </TABLE> </TD> </TR> </TABLE> <P> <!-- Details --> <TABLE CELLPADDING=0 CELLSPACING=0 class=item> <TR> <TD VALIGN=TOP class=itemhead> <B><?php echo $lblDetails;?></B> </TD> </FORM> </TR> <TR> <TD VALIGN=TOP class=leftmenuitem style='color:black' > <BR> <B><?php echo $msg;?></B> <P> <?php echo ($ftp->loggedOn)?"$lblConnectedTo $server:$port ($ftp->systype)":$lblNotConnected;?> <P> <?php echo $lblTransferMode;?> :<?php echo $ftp->mode==1?$lblBinaryMode:$lblASCIIMode;?> <BR><BR> </TD> </TR> </TABLE> </DIV> </TD> <TD VALIGN=TOP> <P> <TABLE WIDTH="650" CELLSPACING=0 CELLPADDING=0 onClick='resetEntries()'> <TR> <TD COLSPAN=2 class=listhead><?php echo $lblName;?></TD> <TD class=listhead><IMG SRC="img/listheaddiv.gif"></TD> <TD class=listhead align=right><?php echo $lblSize;?> </TD> <TD class=listhead><IMG SRC="img/listheaddiv.gif"></TD> <TD class=listhead><?php echo $lblFileType;?> </TD> <TD class=listhead><IMG SRC="img/listheaddiv.gif"></TD> <TD class=listhead><?php echo $lblDate;?></TD> <TD class=listhead><IMG SRC="img/listheaddiv.gif"></TD> <TD class=listhead><?php echo $lblPermissions;?></TD> <TD class=listhead><IMG SRC="img/listheaddiv.gif"></TD> <TD class=listhead><?php echo $lblOwner;?></TD> <TD class=listhead><IMG SRC="img/listheaddiv.gif"></TD> <TD class=listhead><?php echo $lblGroup;?></TD> <TD class=listhead><IMG SRC="img/listheaddiv.gif"></TD> </TR> <?php $list = $ftp->ftpRawList(); if (is_array($list)) { // Directories $counter=0; foreach($list as $myDir) { if ($myDir["is_dir"]==1) { $fileAction = "cd"; $fileName = $myDir["name"]; $fileSize=""; $delAction = "deldir"; $fileType['description'] = 'File Folder'; $fileType['imgfilename'] = 'folder.gif'; } if ($myDir["is_link"]==1) { $fileAction = "cd"; $fileName = $myDir["target"]; $fileSize=""; $delAction = "delfile"; $fileType['description'] = 'Symbolic Link'; $fileType['imgfilename'] = 'link.gif'; } if ($myDir["is_link"]!=1 && $myDir["is_dir"]!=1) { $fileType = fileDescription($myDir["name"]); $fileAction = "get"; $fileName = $myDir["name"]; $image = "file.gif"; if($myDir["size"]<1024) { $fileSize= $myDir["size"] . " bytes "; $fileSize=number_format($myDir["size"], 0, ',', '.') . " bytes"; } else { if($myDir["size"]<1073741824) { $fileSize=number_format($myDir["size"]/1024, 0, ',', '.') . " KB"; } else { $fileSize=number_format($myDir["size"]/1048576, 0, ',', '.') . " MB"; } } $delAction = "delfile"; } ?> <TR> <TD class=filenamecol width=20><A HREF='javascript:selectEntry("<?php echo $fileAction;?>","<?php echo $fileName;?>","filename<?php echo $counter;?>","<?php echo $myDir["perms"];?>","<?php echo $delAction;?>")' ondblclick='submitForm("<?php echo $fileAction;?>","<?php echo $fileName;?>")'><IMG SRC="img/<?php echo $fileType['imgfilename'];?>" ALIGN=TOP BORDER=0></A></TD> <TD class=filenamecol><span id='filename<?php echo $counter;?>'><A HREF='javascript:selectEntry("<?php echo $fileAction;?>","<?php echo $fileName;?>","filename<?php echo $counter;?>","<?php echo $myDir["perms"];?>","<?php echo $delAction;?>")' ondblclick='submitForm("<?php echo $fileAction;?>","<?php echo $fileName;?>")'><?php echo $fileName;?></A></span></TD> <TD> </TD> <TD ALIGN=RIGHT><?php echo $fileSize;?></TD> <TD> </TD> <TD ALIGN=left><?php echo $fileType['description'];?></TD> <TD> </TD> <TD><?php echo $myDir["date"];?></TD> <TD> </TD> <TD><?php echo $myDir["perms"];?></TD> <TD> </TD> <TD><?php echo $myDir["user"];?></TD> <TD> </TD> <TD><?php echo $myDir["group"];?></TD> <TD> </TD> </TR> <?php $counter++; } } else { ?> <TR> <TD colspan=14><BR><B><?php echo $lblDirectoryEmpty;?>...</B></TD> </TR> <?php } print " </TABLE></TD></TR></TABLE>"; } else { if(!isset($msg)) { $msg = "$lblCouldNotConnectToServer $server:$port $lblWithUser $user<P><A HREF='" . $_SERVER["PHP_SELF"] . "'>$lblTryAgain</A>"; unset($_SESSION['server']); unset($_SESSION['user']); unset($_SESSION['password']); unset($_SESSION['port']); session_destroy(); } ?> </TD></TR></TABLE> <HTML> <HEAD> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>NBAS Audits</TITLE> <LINK REL=StyleSheet HREF="style/cm.css" TITLE=Contemporary TYPE="text/css"> <SCRIPT LANGUAGE="JavaScript" SRC="include/script.js"></SCRIPT> </HEAD> <BODY> <?php print $msg; } } else // Still need to logon... { ?> <HTML> <HEAD> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>NBAS Audits</TITLE> <LINK REL=StyleSheet HREF="style/cm.css" TITLE=Contemporary TYPE="text/css"> <SCRIPT LANGUAGE="JavaScript" SRC="include/script.js"></SCRIPT> </HEAD> <BODY> <table align="center"> <tr> <TD COLSPAN=3><IMG SRC="img/logo.jpg" HEIGHT=140 width="329"></TD> </tr> </table> <FORM NAME=login action='<?php echo $_SERVER['PHP_SELF'];?>' METHOD=POST> <TABLE align="center" class=login cellpadding=3> <TR> <TD COLSPAN=3><B> <?php echo $lblLogIn;?></B></TD> </TR> <TR> <TD COLSPAN=3><IMG SRC="img/1px.gif" HEIGHT=60></TD> </TR> <TR> <TD COLSPAN=3> <?php echo $lblConnectToFTPServer;?></TD> </TR> <TR> <TD VALIGN=TOP> <?php echo $lblServer;?></TD> <TD VALIGN=TOP> <?php if($defaultServer == "") { print "<INPUT TYPE=TEXT NAME=server SIZE=15> "; } else { $inputType=($editDefaultServer==true)?"TEXT":"HIDDEN"; print "<INPUT TYPE=" . $inputType . " NAME=server VALUE=" . $defaultServer . ">"; if($editDefaultServer==false) { print "<B>" . $defaultServer . "</B> "; } } ?> </TD> <TD VALIGN=TOP> <TABLE CELLSPACING=0> <TR> <TD><?php echo $lblPort;?></TD> <TD><INPUT TYPE=TEXT NAME=port SIZE=3 VALUE=21></TD> </TR> <TR> <TD><?php echo $lblPasive;?></TD> <TD><INPUT TYPE="checkbox" NAME="goPassive"></TD> </TR> </TABLE> </TD> </TR> <TR> <TD> <?php echo $lblUser;?></TD> <TD> <INPUT TYPE=TEXT NAME=user SIZE=18> </TD> <TD> </TD> </TR> <TR> <TD> <?php echo $lblPassword;?></TD> <TD><INPUT TYPE=PASSWORD NAME=password SIZE=18></TD> <TD><INPUT TYPE=SUBMIT VALUE="Log on"></TD> </TR> <?php if($defaultLanguage == "") { ?> <TR> <TD> <?php echo $lblLanguage;?></TD> <TD colspan=2> <?php ?> <SELECT NAME="language"> <?php if ($handle = opendir('include/language/')) { //Read file in directory and store them in an Array while (false !== ($file = readdir($handle))) { $fileArray[$file] = $file; } //Sort the array ksort($fileArray); foreach($fileArray as $file) { if ($file != "." && $file != ".." ) { $file=str_replace(".lang.php","",$file); $counter=0; foreach($languages as $thislang) { if($thislang==$file) { $counter++; } } if($counter>0) { $langName=strtoupper(substr($file,0,1)) . substr($file,1); ?> <OPTION VALUE="<?php echo $file;?>" <?php echo ($language==$file)?"selected":"";?>><?php echo $langName;?></OPTION> <?php } } } closedir($handle); } ?> </SELECT> </TR> <?php } // End default server ?> <TR> <TD COLSPAN=2><IMG SRC="img/1px.gif" HEIGHT=5></TD> </TR> </TABLE> <TABLE WIDTH=328> <TR> <TD COLSPAN=2 VALIGN=TOP class=leftmenuitem> <P> </TD> </TR> <TR> <TD ALIGN=LEFT> </TD> <TD ALIGN=RIGHT> </TD> </TR> </TABLE> </FORM> <?php } ?> <P> <table align="center"> <tr> <td><script language="Javascript" src="https://seal.godaddy.com/getSeal?sealID=191835474806fd4e690127115b0661fb517ea3022933301964151831"></script></td> </tr> </table> </BODY> </HTML> Quote Link to comment https://forums.phpfreaks.com/topic/79115-upload-files-corrupting/#findComment-400499 Share on other sites More sharing options...
tpearson Posted November 27, 2007 Author Share Posted November 27, 2007 sry...can a mod delete the other post?? Quote Link to comment https://forums.phpfreaks.com/topic/79115-upload-files-corrupting/#findComment-400503 Share on other sites More sharing options...
MadTechie Posted November 28, 2007 Share Posted November 28, 2007 i'm not reading all that!.. sorry unless i get paid or you post a snipplet of where the problem is in that script.. i am not reading the whole thing.. Quote Link to comment https://forums.phpfreaks.com/topic/79115-upload-files-corrupting/#findComment-401566 Share on other sites More sharing options...
tpearson Posted December 3, 2007 Author Share Posted December 3, 2007 i'm not reading all that!.. sorry unless i get paid or you post a snipplet of where the problem is in that script.. i am not reading the whole thing.. right...if i knew where the problem was in the code i would have fixed it, typicaly developer Quote Link to comment https://forums.phpfreaks.com/topic/79115-upload-files-corrupting/#findComment-405045 Share on other sites More sharing options...
MadTechie Posted December 3, 2007 Share Posted December 3, 2007 Debug your code then.. but i'm out! Quote Link to comment https://forums.phpfreaks.com/topic/79115-upload-files-corrupting/#findComment-405163 Share on other sites More sharing options...
cooldude832 Posted December 3, 2007 Share Posted December 3, 2007 if its dying its dying on a certain part specifically not all 10 thousand lines you posted. Figure that out as you shoud lget an error message. That or figure out if its your config not allowing that big of a file to be uploaded. Quote Link to comment https://forums.phpfreaks.com/topic/79115-upload-files-corrupting/#findComment-405167 Share on other sites More sharing options...
tpearson Posted December 4, 2007 Author Share Posted December 4, 2007 if its dying its dying on a certain part specifically not all 10 thousand lines you posted. Figure that out as you shoud lget an error message. That or figure out if its your config not allowing that big of a file to be uploaded. i posted it cause he asked....i honestly dont think its in the code...its either in the php.ini or httpd config but i not famaliar enough to know. I doubt size has anything to do with it...the test files im usin are very small. plain .txt files works fine. im jsut frustrated cause the site where i got this from, the demo works but mine doesnt..and i havent had any responce and was told whoever developed this is MIA. unfortantley this is the best looking web ftp client out there i have seena nd that work minus this part. If anyone knows of another, please let me know. Quote Link to comment https://forums.phpfreaks.com/topic/79115-upload-files-corrupting/#findComment-406070 Share on other sites More sharing options...
PFMaBiSmAd Posted December 4, 2007 Share Posted December 4, 2007 You could have saved most of the trouble with posting that code by simply providing a link to the author's web site. Anyway, I downloaded that script (the problem code is in the ftp.class.php file - another reason to just provide a link to the original script.) It basically has no error checking, error reporting, or error recovery logic. The "upload" code blindly assumes that the upload worked, never checks the ['error'] element, and then ftp's a null file to your FTP server. Since the FTP transfer probably works, the program is dumb and happy. To debug the problem you need to check what the upload error is in the index.php file. The following code will display what you need to find out. I am not sure where to put this so that it does not "break" the web page or get overwritten by what the page outputs, so try it in a few different places. If this gets executed before the upload occurs, it will show blank info. What counts is what it shows after the file is uploaded. echo "<pre>"; print_r($_FILES); echo "</pre>" Quote Link to comment https://forums.phpfreaks.com/topic/79115-upload-files-corrupting/#findComment-406092 Share on other sites More sharing options...
tpearson Posted December 4, 2007 Author Share Posted December 4, 2007 You could have saved most of the trouble with posting that code by simply providing a link to the author's web site. Anyway, I downloaded that script (the problem code is in the ftp.class.php file - another reason to just provide a link to the original script.) It basically has no error checking, error reporting, or error recovery logic. The "upload" code blindly assumes that the upload worked, never checks the ['error'] element, and then ftp's a null file to your FTP server. Since the FTP transfer probably works, the program is dumb and happy. To debug the problem you need to check what the upload error is in the index.php file. The following code will display what you need to find out. I am not sure where to put this so that it does not "break" the web page or get overwritten by what the page outputs, so try it in a few different places. If this gets executed before the upload occurs, it will show blank info. What counts is what it shows after the file is uploaded. echo "<pre>"; print_r($_FILES); echo "</pre>" thank you....i hope this will help. Quote Link to comment https://forums.phpfreaks.com/topic/79115-upload-files-corrupting/#findComment-406106 Share on other sites More sharing options...
PFMaBiSmAd Posted December 4, 2007 Share Posted December 4, 2007 Correction to the code in the above post, it is missing a semi-colon at the end of the third line (that is what you get when you post untested code.) Quote Link to comment https://forums.phpfreaks.com/topic/79115-upload-files-corrupting/#findComment-406436 Share on other sites More sharing options...
PFMaBiSmAd Posted December 5, 2007 Share Posted December 5, 2007 Here is a short test program that will help find out if uploads will work on your server - <?php if(!isset($_POST['submit'])) { echo "Please select a file to upload and press the Submit button<br />"; ?> <form method="post" enctype="multipart/form-data"> <input type="file" name="file"><br /><br /> <input type="submit" name="submit" value="Submit"> </form> <?php } else { echo "Form was submitted<br />"; echo "<pre>"; print_r($_FILES); echo "</pre>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/79115-upload-files-corrupting/#findComment-407239 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.