not submitting as array from form...

See all posts See thread Reply

Re: not submitting as array from form... new!
by dea, 17 years, 6 months ago
The upload is working in the following code, but none of the resizing is. It appears the upload object is not even getting called somehow.

include('/code/upload/class.upload.php');
function makeMyDir($inDirName) {
  $dirArray = split('/', $inDirName);
  $dirName = '/';
  foreach ($dirArray as $dirLevel) {
	$dirName .= $dirLevel.'/';
	if (!file_exists($dirName)) {
	  mkdir($dirName, 0755);
	  echo "making dir... $dirName ...";
	}
  }
}

echo 'Upload result:'; // At least one symbol should be sent to response!

if (count($_FILES) > 0) {
  $uploaddir = $_SERVER['DOCUMENT_ROOT']."/uploads/";  // path to images
  makeMyDir($uploaddir );

  $arrfile = pos($_FILES);
  $uploadfile = $uploaddir . basename($arrfile['name']);

  if (move_uploaded_file($arrfile['tmp_name'], $uploadfile))
	   
	$handle = new upload($uploadfile);
	$handle->image_resize   = true;
    $handle->file_new_name_body   = 'image_resized';
    $handle->image_ratio_y  = true;
    $handle->image_x        = 1024;
	   
    $handle->process($uploadfile);
	   
    echo "File is valid, and was successfully uploaded.\n";
 } else
	echo 'No files sent!'; //Tell Flash we tanked

echo 'Here is some more debugging info:';
print_r($_FILES);
Reply
Re: not submitting as array from form... new!
by colin, 17 years, 6 months ago
Here's the error:
Replace:
$handle->process($uploadfile);
With:
$handle->process($uploaddir);

You can do some logging like this:
$handle->process($uploaddir);
$f = fopen('log', 'a');
fwrite($f, $handle->log);
fclose($f);
And then open the file called log to see what the class does.Reply