Quantcast
Channel: Xojo Programming Forum - Latest topics
Viewing all articles
Browse latest Browse all 3780

Check file name before saving!

$
0
0

Hello everyone,
Here’s the code I put in UploadFinished
But as there will be several sessions at the same time and users will send their photo taken with their smartphone, the name of the file will be by default “image.jpg”, so I would like to add code so that before saving, check if there is not a file with the same name and if so add the time, minutes, seconds or other name to make them unique, do you have an idea?
Thank you very much!

Dim uploadFolder As folderItem
uploadFolder = App.ExecutableFile.Parent.Child(“UploadedPictures”)
If Not uploadFolder.Exists Then
#If DebugBuild Then
uploadFolder.CreateFolder
#Else
MsgBox(“Upload failed”)
Return
#Endif
End If

Dim uploadedPicture As Picture
Dim savePicture As FolderItem

For Each uFile As WebUploadedFile In files
Try
If uFile.file <> Nil Then
uploadedPicture = Picture.Open(uFile.File)
Else
uploadedPicture = Picture.FromData(uFile.data)
End If

// Save the file to disk
savePicture = uploadFolder.Child(uFile.Name)
uFile.Save(savePicture)

Catch err As IOException

Exit For

End Try
Next

MessageBox(“ok”)

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 3780

Trending Articles