Created
January 29, 2013 20:01
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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