• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
File Upload

#1
Good day, does anyone have a clue how the file upload for igniter4 is supposed to work??

been having lot of failed attempts
Reply

#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.
Practical CodeIgniter 3  • CodeIgniter 4 Foundations - Coming Soon • Vulcan - CLI Tools for CI4
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.