Koa-better-body file uploading not working - koa2

I'm using Koa-better-body with Koa2, and I want to handle single file uploads in a POST form submission (input type=file).
While all the other fields show up properly under ctx.request.fields, i.e. ctx.request.fields.title, my file input's contents simply aren't available!
Interestingly,under ctx.request.fields, I still get a value for my file input (ctx.request.fields.coverimage), but that only gives me a file-name string, not the actual file (a cover image in this case).
What am I missing!

I bet that you forgot to add to your form:
enctype="multipart/form-data"

Related

File type input field found empty when come back to the previous step in formik wizard

I have created multi-step form using formik-wizard, I added file type input field in first step but if I go to 2nd step and come back to 1st step then file input field found empty.
How can I solve this issue ?
Here is my code example on codesandbox.
Formik doesn't support file upload by default, but you can try the solution by following the link:
ReactJS: How to handle Image / File upload with Formik?
You can store the file value in a state variable and use it during form submission.

How to handle input file validation using html form

I have try to form validation with input type file . When i try to validate attached files missing. I need to again and again upload the files in form. Anyone can share how to avoid this issues

Why is the file object empty inside formik's values object on file upload form?

I'm trying to upload a file using formik but the file object is always empty and I cannot quite figure it out. Here is a link to the codesandbox - https://codesandbox.io/s/formik-file-input-with-validation-forked-r5jqg?file=/src/App.js
I got this implementation from this issue filed on github - https://github.com/formium/formik/issues/926.
Your help would be greatly appreciated.
You were setting an object which was e.target.files[0] to a file which was initially undefined. you need to set e.taregt.files[0] to reader.readAsDataURL(file). not to your state object file too. you need to set name and size as that is what you need for validation schema and display. I've commented the supported formats from validation schema as for input type=file you can directly mention the accepted formats by accept key.
Here is my working modified sandbox.

Orbeon - how to validate file content uploaded by user

I need to validate content of pdf file sent by "File Attachement" component, using Webservice, uploaded by user.
How to do that ?
Action Value Change is not called
ver.orbeon-4.4.0.201311042036-PE
Thanks
Piotr
That probably requires a few steps:
Determine when the upload is complete. With recent versions of Orbeon Forms, the eventxxforms-upload-done can be used.
Send the content of the uploaded file to a service. The file can be a binary file, but there is a way to submit binary content.
Depending on what the service returns, mark the control valid or invalid. You could do this with an attribute on the element holding the uploaded file's URL, e.g.: <my-upload valid="true"/> and then use a constraint like constraint="#valid = 'true'".

Drupal Attachments (FileField) file path

What function in Drupal gets file attachment path?
Edit: the attachments provided by Upload module in system section. But since you mentioned there may be another way around it. Maybe I could achieve may goals using FileField module so if you could tell me how to get a direct link of a file uploaded by FileField module that may also be very helpful.
Edit 2:
Ok I will start from my main and final objective:
It is to get an image linking to a file which visibility I could be managed using CCK module.
I am doing this step by step. So now I have written a code which generates the needed image and I have added that image to one of content types teaser. I found a way to warp my image in a tag and I had dug up simple attachments url. So my next step is to advance from simple upload attachment to the one added by FileFields and from odd looking HTML pace in all PHP document into beautifully managed CCK field.
How to fetch file path of a file uploaded FileFields?
Some plain and at the same time rich tutorials for making custom fields for CCK module.
Assuming you know how to get the $node object for a node containing a file attachment, this is super easy:
Upload (core)
$file = upload_load($node);
echo $file[1]->filepath;
Where 1 is the index of the file. Upload can let you upload more than one file, so file 2 would have an index of 2 and so on. If there's only one file, it'll always be 1.
More info: upload_load() API reference.
FileField
echo $node->field_fieldname[0]['filepath'];
Where field_filename is the short name you've used for the field, and 0 is the index of the field. CCK fields let you have multiple values in one field, so 0 would be the first, 1 would be the second, etc. If you only have one value, it'll always be 0.
Note: if you want to get the rendered output of the FileField using its formatters, you can just use $field_fieldname in your node template, or if you want to store the rendered output, you can use:
echo content_format('field_fieldname', $node->field_fieldname[0]);
More info: content_format() API reference.
Upload is a sad little module, and has been completely replaced with a core implementation of FileField in Drupal 7. If you have the option to use FileField, you should.
Don't direct links of file attachments appear below the uploaded file for the core Upload module?
Since you are trying to use images, you should use http://drupal.org/project/imagefield CCK module in order to add images to specified content type. After that using the Display fields tab in Content type configuration you can specify how image would be presented (as a link, image, image with link to node...) both in teaser and body view.

Resources