Skip to content

Instantly share code, notes, and snippets.

@jordiwes
Created January 29, 2013 20:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jordiwes/4667235 to your computer and use it in GitHub Desktop.
Save jordiwes/4667235 to your computer and use it in GitHub Desktop.
Here is my file upload code. You'll notice that the validator is commented out, this is not because it didn't work, it's because I don't need it. It's an internal application and doesn't need any validaiton.
use Zend\File\Transfer\Adapter\Http;
$adapter = new Http();
//$size = new Size(array('min'=>2000)); //minimum bytes filesize
//$adapter->setValidators(array($size), $File['name']);
/*if (!$adapter->isValid()){
$dataError = $adapter->getMessages();
$error = array();
foreach($dataError as $key=>$row)
{
$error[] = $row;
}
} else {
*/
$currentPath = explode("/", dirname(__DIR__));
$directory = "/" . $currentPath[1] . "/" . $currentPath[2] . "/uploads/" . $appt . "/";
//see if the directory is created:
if (!file_exists($directory))
{
mkdir($directory);
}
$adapter->setDestination($directory);
if ($adapter->receive($uplfile['name'])) {
$rtn["success"] = "true";
}
else
{
$rtn["success"] = "false";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment