Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty html-file created when moving uploaded files with $img->move() #4020

Closed
ivanBell199 opened this issue Dec 22, 2020 · 2 comments
Closed

Comments

@ivanBell199
Copy link
Contributor

ivanBell199 commented Dec 22, 2020

I have tried to implement file uploading using the example from the Codeigniter 4 documentation. In my controller I have this code:

if($imagefile = $this->request->getFiles())
{
   foreach($imagefile['images'] as $img)
   {
      if ($img->isValid() && ! $img->hasMoved())
      {
           $newName = $img->getRandomName();
           $img->move('img/folder1/folder2', $newName);
      }
   }
}

This code nicely saves the uploded files in the "folder2" directory. However it also creates an empty html-file in the "folder2" directory. This file is named "folder2index". This behavior is undesired, because I simply need to upload a few files without anything else. For now I have just added some code to automatically remove the html-file.

@iRedds
Copy link
Collaborator

iRedds commented Dec 22, 2020

Add a slash in the end of the path img/folder1/folder2/ <-
You will get the correct index.html file.
if you don't need index.html you can create your own logic to move uploaded files.

@michalsn
Copy link
Member

michalsn commented Jan 2, 2021

I guess we can say it's solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants