I have been trying since 3 days ago to see how i can select multiple images using any package that works wit expo but to no avail, I ave tried ImagePicker but only allows one picture to be selected, tried couple of other packages but keep getting errors, I also have been trying expo-image-picker-multiple latest version but it keeps showing errors.
So i was finally able to select multiple image from gallery and upload using below
to get expo-image-picker-multiple to work, use version 1.0.6 and then go to the source file in node modules and find ImageBrowser file and replace the prepareCallback function with below code
prepareCallback() {
const { selected, photos } = this.state;
const selectedPhotos = selected.map(i => photos[i]);
this.props.callback(selectedPhotos); }
and then go to ImageBrowserScreen file and replace imagesCallback function wit below code
imagesCallback = (photos) => {
const { navigation } = this.props;
this.props.navigation.setOptions({
headerRight: () => this._getHeaderLoader()
});
console.log(2);
const cPhotos = [];
for(let photo of photos) {
cPhotos.push({
uri: photo.uri,
name: photo.filename,
type: 'image/jpg'
})
}
console.log(3);
console.log(cPhotos);
navigation.navigate('post_ad', {photos: cPhotos}); };
Upgrade to Expo SDK 46+ and you are able to set the ImagePicker to grab multiple files (works on Web, Android and IOS14+).
let result = await ImagePicker.launchImageLibraryAsync({
allowsMultipleSelection: true,
selectionLimit: 4,
});
The response contains uri
for each file (among other data).
result.map(async (img) => {
const url = await handleImageUpload(img.uri)
})
The Expo documentation is excellent.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.