0

I have a file input in my application (ionic 6 and vue 3) and when the it is triggered in iOS i get this three options.

Input File options

I found here that some searching that these are OS defaults and cannot be changed.

So now the question is there a way to identify if the user has chosen TAKE PHOTO option and trigger the camera action like stated here in Ionic docs.

i.e if the PHOTO LIBRARY or FILES is chosen it follows the current path. But incase of TAKE PHOTO to have additional handling to handle the images.

How can i handle this ?

I am currently using the following code to handle the selection of file and upload of it when a button is clicked and a hidden input.

const selectFile = (event: any) => {
  attachmentFile.value = event.target.files[0];
  uploadAttachment();
};

const uploadAttachment = async () => {
  const file = attachmentFile.value;
  if (!file) return;
  const path = `${student_profile.value?.id}/${selectedType.value}-${file.name}`;
  const data = await uploadFileToStorage({ path: path, file: file });
  if (data) saveAttachmentMetaData(data.publicUrl);
};

HTML for buttons and file input

    <ion-item style="display: none">
      <input
        type="file"
        accept=".pdf,.doc,.docx,image/*"
        @change="selectFile($event)"
        ref="fileInput"
      />
    </ion-item>

    <ion-button
      @click="fileInput?.click()"
      :disabled="!selectedType"
      expand="block"
      >Select File</ion-button
    >
thezohaan
  • 324
  • 1
  • 10

0 Answers0