runnerjp Posted April 13, 2012 Share Posted April 13, 2012 I have inherited some code and i cant seem to find where it uploads the image to a folder anywhere. It adds it to the database but not to any folder. Can any one see where it does this atall?? File attached as code to long to paste. 18065_.php Quote Link to comment Share on other sites More sharing options...
Jessica Posted April 13, 2012 Share Posted April 13, 2012 You didn't need to attach all of that. It looks like it's happening in the function upload_file_cms which is not defined in the attached file. Quote Link to comment Share on other sites More sharing options...
runnerjp Posted April 13, 2012 Author Share Posted April 13, 2012 // file upload function function SendResults( $errorNumber, $customMsg = '' ) { echo '<script type="text/javascript">' ; echo 'window.parent.OnUploadCompleted(' . $errorNumber . ',"' . $customMsg . '") ;' ; echo '</script>' ; exit ; } function GetRootPath() // from admin { $sRealRootPath = realpath( '../' ) ; return $sRealRootPath; } function GetRootPathCMS() { $sRealRootPath = realpath( './' ) ; return $sRealRootPath; } function GetURLPathFromAdmin() // from admin { $sRealPath = realpath( './' ) ; $sRootRealPath = realpath( '../' ) ; $sRealPathFromRoot = substr( $sRealPath, strlen( $sRootRealPath ), strlen( $sRealPath ) ); $sSelfPath = $_SERVER['PHP_SELF'] ; $sSelfPath = substr( $sSelfPath, 0, strrpos( $sSelfPath, '/' ) ) ; $sURLPath = substr( $sSelfPath, 0, strlen( $sSelfPath ) - strlen( $sRealPathFromRoot ) ); return $sURLPath; } function GetURLPath() // from root app { $sRealPath = realpath( './' ) ; $sRootRealPath = realpath( './' ) ; $sRealPathFromRoot = substr( $sRealPath, strlen( $sRootRealPath ), strlen( $sRealPath ) ); $sSelfPath = $_SERVER['PHP_SELF'] ; $sSelfPath = substr( $sSelfPath, 0, strrpos( $sSelfPath, '/' ) ) ; $sURLPath = substr( $sSelfPath, 0, strlen( $sSelfPath ) - strlen( $sRealPathFromRoot ) ); return $sURLPath; } function RemoveExtension( $fileName ) { return substr( $fileName, 0, strrpos( $fileName, '.' ) ) ; } function RemoveFromStart( $sourceString, $charToRemove ) { $sPattern = '|^' . $charToRemove . '+|' ; return preg_replace( $sPattern, '', $sourceString ) ; } function RemoveFromEnd( $sourceString, $charToRemove ) { $sPattern = '|' . $charToRemove . '+$|' ; return preg_replace( $sPattern, '', $sourceString ) ; } function remove_directory($dir) { if ($handle = opendir("$dir")) { while (false !== ($item = readdir($handle))) { if ($item != "." && $item != "..") { if (is_dir("$dir/$item")) { remove_directory("$dir/$item"); } else { unlink("$dir/$item"); } } } closedir($handle); rmdir($dir); } } function upload_file($uploadFileName, $uploadDirectory, $admin_area = true) { //upload new img title if ($admin_area) $sServerDir = GetRootPath() . $uploadDirectory; else $sServerDir = GetRootPathCMS() . $uploadDirectory; // Get the posted file. $oFile = $_FILES[$uploadFileName] ; // Get the uploaded file name $sFileName = $oFile['name'] ; $sOriginalFileName = $sFileName ; $sExtension = substr( $sFileName, ( strrpos($sFileName, '.') + 1 ) ) ; $sExtension = strtolower( $sExtension ) ; // Initializes the counter used to rename the file, if another one with the same name already exists. $iCounter = 0 ; while ( true ) { // Compose the file path. $sFilePath = $sServerDir . '/' . $sFileName ; // If a file with that name already exists. if ( is_file( $sFilePath ) ) { $iCounter++ ; $sFileName = RemoveExtension( $sOriginalFileName ) . '(' . $iCounter . ').' . $sExtension ; } else { move_uploaded_file( $oFile['tmp_name'], $sFilePath ) ; if ( is_file( $sFilePath ) ) { $oldumask = umask(0) ; chmod( $sFilePath, 0777 ) ; umask( $oldumask ) ; } break ; } } return $sFileName; } function upload_file_cms($uploadFileName, $uploadDirectory) { //upload new img title $sServerDir = ROOT_PATH . $uploadDirectory; // Get the posted file. $oFile = $_FILES[$uploadFileName] ; // Get the uploaded file name $sFileName = $oFile['name'] ; $sOriginalFileName = $sFileName ; $sExtension = substr( $sFileName, ( strrpos($sFileName, '.') + 1 ) ) ; $sExtension = strtolower( $sExtension ) ; // Initializes the counter used to rename the file, if another one with the same name already exists. $iCounter = 0 ; while ( true ) { // Compose the file path. $sFilePath = $sServerDir . '/' . $sFileName ; // If a file with that name already exists. if ( is_file( $sFilePath ) ) { $iCounter++ ; $sFileName = RemoveExtension( $sOriginalFileName ) . '_' . $iCounter . '_.' . $sExtension ; } else { move_uploaded_file( $oFile['tmp_name'], $sFilePath ) ; if ( is_file( $sFilePath ) ) { $oldumask = umask(0) ; chmod( $sFilePath, 0777 ) ; umask( $oldumask ) ; } break ; } } return $sFileName; } Quote Link to comment Share on other sites More sharing options...
MMDE Posted April 13, 2012 Share Posted April 13, 2012 Have you edited the code a all? $sServerDir = ROOT_PATH . $uploadDirectory; ^ At first glance this seems to be the place where it saves the images. Unless there is something I'm missing, then this would compile with a syntax error, because of ROOT_PATH. Have you tried turning on error reporting? Quote Link to comment Share on other sites More sharing options...
runnerjp Posted April 13, 2012 Author Share Posted April 13, 2012 No its been moved from anouther server thats all i have also added <?php // Turn off all error reporting error_reporting(0); // Report simple running errors error_reporting(E_ERROR | E_WARNING | E_PARSE); // Reporting E_NOTICE can be good too (to report uninitialized // variables or catch variable name misspellings ...) error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); // Report all errors except E_NOTICE // This is the default value set in php.ini error_reporting(E_ALL ^ E_NOTICE); // Report all PHP errors (see changelog) error_reporting(E_ALL); // Report all PHP errors error_reporting(-1); // Same as error_reporting(E_ALL); ini_set('error_reporting', E_ALL); ?> to each page with no errors Quote Link to comment Share on other sites More sharing options...
RobertP Posted April 13, 2012 Share Posted April 13, 2012 No its been moved from anouther server thats all i have also added <?php // Turn off all error reporting error_reporting(0); // Report simple running errors error_reporting(E_ERROR | E_WARNING | E_PARSE); // Reporting E_NOTICE can be good too (to report uninitialized // variables or catch variable name misspellings ...) error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); // Report all errors except E_NOTICE // This is the default value set in php.ini error_reporting(E_ALL ^ E_NOTICE); // Report all PHP errors (see changelog) error_reporting(E_ALL); // Report all PHP errors error_reporting(-1); // Same as error_reporting(E_ALL); ini_set('error_reporting', E_ALL); ?> to each page with no errors you use 7 function calls, uhmm ok, i think u need only 1 Quote Link to comment 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.