Comments (6)
Thanks for submitting a ticket. I had not considered this use-case before, having not used much JS as a front-end. It is focused, as you rightly say, on being posted from PHP.
I would think that updating the request data before it is marshalled would be a good solution.
from cakephp-proffer.
I'll give it a go - thanks for tip on where to start. I'll post my findings.
from cakephp-proffer.
I'm not sure how I can set the tmp_name manually with a valid value because although I can easily set an arbitrary value how can I know the random name used for each image temporarily stored, for example these are town examples:
'tmp_name' => 'C:\wamp64\tmp\php6B85.tmp',
'tmp_name' => 'C:\wamp64\tmp\php7318.tmp',
If this is set by PHP how can it be set manually in my Cake app?
Note added: seems I may need access to $_FILES but within my cake app this is empty.
from cakephp-proffer.
Hmm, perhaps it's worth looking at https://github.com/FriendsOfCake/cakephp-upload and using a custom Writer class and a custom transformer to generate thumbnails using a library of your choice.
I've not used Angular, so I've no idea how it uploads files.
from cakephp-proffer.
So actually this is a lot simpler than I imagined and all the work which is required is on the front-end side.
What I had to do was use a FormData object to set the file data which then resulted in the file attributes are passed before make the call to the Cake backend:
var dataObj = new FormData();
angular.forEach($scope.listing.listing_images, function(value, key) {
dataObj.append('listing_images[' + key + ']', value);
});
$http({
method: 'post',
url: frontbaseurl + '/api/listings.json',
data: dataObj,
headers: {'Content-Type': undefined},
});
This wasn't obvious to me because to date when posting to the back-end I have simply been passing an object with attributes for each field to be saved. The idea of using a formData object is new but seems to be the solution.
Feel free to close this 'issue'. Thanks!
from cakephp-proffer.
Glad you figured it out @spacebiscuit, good thought to use a formData object 👍
from cakephp-proffer.
Related Issues (20)
- Depreciation Cake 3.6 HOT 1
- Inconsistent behavior with large image uploads HOT 1
- Generate task fails if file is not an image HOT 1
- Deprecation Message
- Proffer doesn't create a value for scource_dir in the entity HOT 3
- Error to Upload multiple images HOT 1
- I can't use multiple upload HOT 7
- Deprecated error HOT 1
- Upgrade Proffer to CakePHP 4 HOT 4
- Issue with deleting file - CakePHP 4 HOT 4
- Documentation examples improvements HOT 1
- Upload to aws s3 HOT 2
- Afterpath Event Question HOT 3
- Getting the file object in the filename field instead of the filename and dir.
- Can't upload HOT 1
- Multi-Upload don't work HOT 1
- Proffer for cake4 does not download HOT 4
- how to save mimetype in db HOT 1
- Error while trying to delete optional files HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cakephp-proffer.