Welcome Guest, Not a member yet? Register   Sign In
File Upload
#2

Looks like there was an issue with file extensions on uploaded files. That should be fixed now. Please download the latest version and try again.

Here's some extremely ugly code to give you an idea of some of the things you can do:

Code:
public function upload()
{
if  ($this->request->getMethod() == 'post')
{
$this->validate([
'avatar' => 'uploaded[avatar]|ext_in[avatar,png,jpg,jpeg,gif]'
]);

/**
* @var \CodeIgniter\HTTP\Files\UploadedFile
*/
$file = $this->request->getFile('avatar');

echo "Name: {$file->getName()}<br/>";
echo "Temp Name: {$file->getTempName()}<br/>";
echo "Random Name: {$file->getRandomName()}<br/>";
echo "Extension: {$file->getExtension()}<br/>";
echo "Client Extension: {$file->getClientExtension()}<br/>";
echo "Guessed Extension: {$file->guessExtension()}<br/>";
echo "MimeType: {$file->getMimeType()}<br/>";
echo "IsValid: {$file->isValid()}<br/>";
echo "Size (b): {$file->getSize()}<br/>";
echo "Size (kb): {$file->getSize('kb')}<br/>";
echo "Size (mb): {$file->getSize('mb')}<br/>";
echo "Size (mb): {$file->getSize('mb')}<br/>";
echo "Path: {$file->getPath()}<br/>";
echo "RealPath: {$file->getRealPath()}<br/>";
echo "Filename: {$file->getFilename()}<br/>";
echo "Basename: {$file->getBasename()}<br/>";
echo "Pathname: {$file->getPathname()}<br/>";
echo "Permissions: {$file->getPerms()}<br/>";
echo "Inode: {$file->getInode()}<br/>";
echo "Owner: {$file->getOwner()}<br/>";
echo "Group: {$file->getGroup()}<br/>";
echo "ATime: {$file->getATime()}<br/>";
echo "MTime: {$file->getMTime()}<br/>";
echo "CTime: {$file->getCTime()}<br/>";

                       $file->move($destination);

dd($file);
}

echo <<<EOF
<!doctype html>
<html>
<body>

<form action="" method="post" enctype="multipart/form-data">

<input type="file" name="avatar">

<input type="submit" value="Upload">

</form>

</body>
</html>

EOF;
;
}

Oh - and remember it's pre-alpha quality software at the moment. Bugs should be expected. Any help diagnosing those bugs is always helpful.
Reply


Messages In This Thread
File Upload - by scalla - 07-06-2017, 09:43 AM
RE: File Upload - by kilishan - 07-06-2017, 11:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB