57Burst 0 Newbie Poster

The following function should add pdf's to the $dest folder but fails at Break2. I added the Breaks so I could see where the problem was. The function is called from a form that allows me to add up to 10 pdf's per property. The jpeg function which also allows me to add up to 10 jpeg's works fine.

<?php

function pdf ( $src, $srcFormat, $dest, $destFormat = "application/pdf" )

{
  echo $src;
  echo $srcFormat;
  error_log ( "Trying to read source file from \"" . $src . "\"" );
  error_log ( "Trying to write destination file to \"" . $dest . "\"" );

  $readFunctions = array ();
  $readFunctions [ "application/pdf" ] = "pdf";


  $writeFunctions = array ();
  $writeFunctions [ "application/pdf" ] = "pdf";


  if ( ! isset ( $readFunctions [ $srcFormat ] ) ||
      	   ! function_exists ( $readFunctions [ $srcFormat ] ) )
  {
    echo "Break1";
    error_log ( "Can't find file load function \"" .
    $readFunctions [ $srcFormat ] . "\"" );
    
	return false;
  }

  if ( ! isset ( $writeFunctions [ $destFormat ] ) ||
        ! function_exists ( $writeFunctions [ $destFormat ] ) )
  {
	error_log ( "Can't find file save function \"" .
    $writeFunctions [ $destFormat ] . "\"" );
    echo "Break2";
	return false;
  }
  echo $srcFile = @call_user_func ( $readFunctions [ $srcFormat ], $src );

  if ( ! $srcFile )
     {
     error_log ( "unable to load file from " . $src . " with user function " .
         $readFunctions [ $srcFormat ] );
     echo "Break3";
	 $scrFormat;
	 return $srcFormat;
  }
  echo "Break4";
  @call_user_func ( $writeFunctions [ $destFormat ], $src, $dest );
  echo "Break5";
  @filedestroy ( $src );
  @filedestroy ( $srcImage );

  return true;
}

?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.