FriendsOfCake / cakephp-upload

CakePHP: Handle file uploading sans ridiculous automagic
https://cakephp-upload.readthedocs.io/
MIT License
551 stars 255 forks source link

Multiple Images DB saving but no images on server #419

Closed spacebiscuit closed 2 years ago

spacebiscuit commented 7 years ago

HI,

I am uploading multiple images on a dingle field, all databse tables are saved correctly;

<?= $this->Form->create($listing, ['type' => 'file']) ?>           
       <?= $this->Form->input('listing_images[]', ['type' => 'file', 'multiple' => true]) ?>
       <?= $this->Form->button(' Save') ?>
<?= $this->Form->end() ?>

Entries appear in the listing_images table with the fk correctly set but I no files are on my server. I have set the path to be:

'path' => WWW_ROOT . 'test' . DS,

I've created the folder in my webroot but nothing inside. I am on a windows box running WAMP on localhost. I have tested a custom upload script and that allows me to upload a file so it doesn't appear to be a server issue.

Any ideas?

TY.

josegonzalez commented 7 years ago

You will need to ensure that directory is writeable by the process running your webserver.

spacebiscuit commented 7 years ago

Thanks - single upload work so looks like perms are fine. This is how I have the behavior setup

'listing_images[]' => [],

spacebiscuit commented 7 years ago

Has this been tested for multiple images on a single upload field? Could I be reporting a feature which isn't supported?

josegonzalez commented 7 years ago

I've not written any tests for that, but I have tested multiple file uploads at once. It should work fine since the cake callback system is scoped per-entity.

spacebiscuit commented 7 years ago

I'm certain that it doesn't work, I've tested this comprehensively, The best I can do is save the related hasMany db entries, the files themselves are not processed.

josegonzalez commented 7 years ago

Can you gist what the output form html looks like?

josegonzalez commented 7 years ago

Sorry, at work, otherwise I'd be inclined to test this out again now.

spacebiscuit commented 7 years ago

Sure this is the form mark-up:

https://gist.github.com/spacebiscuit/19a3d4f191a2924ab92cf44a5b5b53cf

josegonzalez commented 7 years ago

What are the contents of $this->request->data?

spacebiscuit commented 7 years ago

$this->Request->data added to the gist:

https://gist.github.com/spacebiscuit/19a3d4f191a2924ab92cf44a5b5b53cf

spacebiscuit commented 7 years ago

I tried all day to try and modify the plugin to process multiple images, I cannot figure out the basics because there is some very odd behavior occurring that makes testing this next to impossible, I think it might be easier to just write my own module to handle this as the pluginlooks like it might be overkill for my needs.

josegonzalez commented 7 years ago

Can you gist your two models, as well as the controller code? Based on how callbacks work in CakePHP, the submitted data looks fine and it should be saving stuff to disk.

I'm going to assume saving a single file works.

spacebiscuit commented 7 years ago

Models as requested:

https://gist.github.com/spacebiscuit/4539b812fd0bba2a3bea9c0b3b3ecf5b

I think the problem is in the beforeSave of uploadedBaehvior in the plugin. It's expecting a single array for the file upload not an arrya of arrays. I thought I could probably wrap this in a loop but it looks like there is more work required.

josegonzalez commented 7 years ago

Right, but each entry in that array should be saved individually, not as a group, so this tells me that its something upstream is going wrong. Let me see if I can get a reproduction in today.

spacebiscuit commented 7 years ago

BTW remember that the hasMany table saves correctly so it doesn't look to be a problem with the relations between models.

josegonzalez commented 7 years ago

Yeah thats why it's strange. We should only be getting a single record in that save call, not every record.

nifa-dev commented 6 years ago

Has there been any progress on this front? I feel as thought I have a similar related use, but can't seem to get my head around it. In my case, the database records aren't being created either. The set up is nearly identical to that of the OP.

saeideng commented 2 years ago

no recent activity, then, closing ... if you had any issue ask in cake support channels