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

Rename file according to input name #873

Closed
Beiusxzw opened this issue Jun 21, 2020 · 2 comments
Closed

Rename file according to input name #873

Beiusxzw opened this issue Jun 21, 2020 · 2 comments

Comments

@Beiusxzw
Copy link

In my html:

<a href="javascript:;" class="file_a">
     <input type="file" name="file1" nv-file-select uploader="uploader"  />
</a>

and my uploader:

   uploader.onAfterAddingFile = function(fileItem, e) {
        var fileName = fileItem.file.name.split('.');
        if (fileName.length < 2) {
            alert("Uploaded file must have a valid extension! For more information see the Supported Formats")
        }
        var fileExtension = "." + fileName.pop();
        fileItem.file.name = e + fileExtension;
        console.info('onAfterAddingFile', fileItem);
    }

I wonder if I can retrieve the name of the input and rename the uploaded file? Thanks!

@ygj6
Copy link
Collaborator

ygj6 commented Jul 2, 2020

Your method can modify the file name.
Does this example meet your requirements: c7891da
The final server receives the modified name:
aaaa

@Beiusxzw Beiusxzw closed this as completed Jul 6, 2020
@Beiusxzw
Copy link
Author

Beiusxzw commented Jul 6, 2020

problem solved. Thanks!

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

No branches or pull requests

3 participants
@ygj6 @Beiusxzw and others