Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get the file name of file uploaded #76

Open
princyphlp opened this issue Jul 27, 2017 · 4 comments
Open

Get the file name of file uploaded #76

princyphlp opened this issue Jul 27, 2017 · 4 comments

Comments

@princyphlp
Copy link

princyphlp commented Jul 27, 2017

Hi, We have the SPWidget Upload control embedded in the edit list form. So we have encountered users selecting file from the desktop, but forget to click on Upload button, instead they submit the edit form with Save Click.

How do we check if the file was uploaded in PreSave function.

@purtuga
Copy link
Owner

purtuga commented Jul 27, 2017

I'm not sure what PreSave is...
The Upload widget emits "change" events when the user interacts with it (ref). You can use that to run code when user selects a file, but does not click on the "upload" button. Something like:

$(yourContentEle).SPControlUpload({
   ...
   onPagePage: function(ev){
       if (ev.state === 2) {
           // user selected a file, but upload has not happen yet.
       }
   }
})

You should then be able to track whether the user has actually uploaded the file or not...

/Paul.

@princyphlp
Copy link
Author

Tested it, unfortunately this message is fired when I click on the Upload button.
2017-07-28_10-05-35

@princyphlp
Copy link
Author

As you can see, I want to check if the file is selected when the Save button is clicked.
Users sometimes select the file but ignore to click on the Upload button instead click on Save. I tried with the above recommendation and for
if (ev.state = 2)
alert("user selected a file, but upload has not happen yet.");

above code is fired when the Upload button is hit.

@purtuga
Copy link
Owner

purtuga commented Jul 28, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants