I use Cloud Code and Express hosted on Parse to upload images.
Here is the Parse log error:
I2015-01-03T13:35:55.199Z] TypeError: Cannot read property 'thumbnail' of undefined at app.js:40:25 at callbacks (express_router.js:161:37) at param (express_router.js:135:11) at pass (express_router.js:142:5) at Router._dispatch (express_router.js:170:5) at Object.router (express_router.js:33:10) at next (connect_proto.js:240:15) at Object.expressInit [as handle] (express_middleware.js:31:5) at next (connect_proto.js:240:15) at Object.query [as handle] (connect_query.js:44:5)
Express JS / Parse seems to be unable to understand req.files.XXX. An error appears in app.js in the following line: console.error (req.files.thumbnail.size);
In addition, req.files prints the following error: No Message
Here is the recipecontent.ejs code:
<!DOCTYPE html> <html> <form method="post" enctype="multipart/form-data" action="/saverecipecontent"> Enter Recipe Image 1: <input type="file" name="thumbnail" id="thumbnail"> <input type="submit"> </form> </html>
Here is the app.js code:
Finally, here is the main.js code:
require('cloud/app.js'); Parse.Cloud.define("saveRecipeImage", function(request, response) { var recipeContent = Parse.Object.extend("recipe_content"); var recipeContentObj = new recipeContent(); console.error(request.params); var file = request.params.thumbnail; var name = "photo.jpg"; var parseFile = new Parse.File(name, file); parseFile.save().then(function(parseFile) {
Please, help!
source share