Link to home
Start Free TrialLog in
Avatar of janhoedt
janhoedt

asked on

Webpage which can upload a file and create json with info when submit

Hi,

I d like to make a small webpage which can:
-upload an executable file or msi
-gets the ad user who uploads this file and set info on the file and user in a json file when the user clicks submit

Maybe nodejs can do this?
Please advise howto.
J
Avatar of gelonida
gelonida
Flag of France image

1.) I'm not 100% sure I got the requirements right.

so if I understand you want to have a small web server, where you have to authenticate with active directory (LDAP)

Then the user gets a form, where one can select a file to upload, and it can be uploaded.

Then there is another page where everybody (or just certain users who authenticated with AD) can consult the lists of uploaded files along with the user who uploaded and when clicking on the file they receive a json with information about the file.


2.) It seems, that what you need is active directory authentication, so any server which can handle active directory should be fine.
so yes, node, python, php, .net, java and others can implement such a solution.

The right choice depends on the languages, that you know, the services already available, whether you implement this on a machine where you have full access or on a server where you have limited access (and thus choice of language / frame works)

Perhaps also important to know whether this is an intranet side / a public available site, how much activity you're expecting
Avatar of janhoedt
janhoedt

ASKER

Intranet, some 100 users
Well you can use nodejs or almost any other (python, php, .net, java, go ...) to implement a solution.

If possible I'd choose either a framework or language, that's already used at your site or the one that you want to learn or the one where you can learn / work together with somebody)

Advise which language / framework you'd like to use.
Afterwards you have three things to try out / to learn.

1.) How to upload a file
2.) How to perform AD authentification
3.) where to store the meta data (ad user, who uploadeed a file) a small meta file nest to each uploaded file? An sqlite database? another db?
Powershell and json
ASKER CERTIFIED SOLUTION
Avatar of gelonida
gelonida
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
One json per document.
Nodejs/javascript is ok. I can put output of query powershell in any format, like JSON so nodejs can query that.
For lack of any clear answer or solution.
I think the reason for not getting a clear solution is this is one of those things that seems easy and straight forward but as dive into what is required it gets more complicated.  The answers gelonida provided are as about as detailed as can be achieved with the information provided.  With something like this, you have step one complete, now on to step 2, 3 and 4 to finish up.


The first part of your question was, "I d like to make a small webpage which can: -upload...."  The html below will do just that.
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Upload Page</title>
</head>
<body>
<form action="upload.php" method="post" enctype="multipart/form-data">
    Select file to upload:
    <input type="file" name="fileToUpload" id="fileToUpload">
    <input type="submit" value="Upload File" name="submit">
</form>
</body>
</html>

Open in new window

However, this is just the front end. Where it becomes complex is the back end.

Step 2 is going to be using server side code to accept the file and save it to the server.

Step 3 is checking to make sure the file type is what you are expecting.

Step 4 is finishing up by moving the file from the temporary saved location to the final location and sending back data to the front end that the file is either accepted or rejected.

One gotcha here is going to allow exe or mis files to be uploaded via the internet as this is most likely going to be turned off by default.

The other part of your question is not 100% clear.  "gets the ad user who uploads this file ...." Getting the user information should be part of your log procedure that can be later used as part of your upload processing page. You should not have to place this data on the front end html.  It is the second part of this that I am a bit confused. "...and set info on the file and user in a json file when the user clicks submit"  I am not sure what you mean by set info on the file since you are having the user upload a file that can not be altered. Do you mean to upload a second file behind the scenes. Like I said, it is possible this information can be accessed on the back end.

The Experts here are typically  not going to write out code from scratch for something like this. The expectation is for you as the asker to provide some code you have tried and let us know any specific errors you are getting and we can help trouble shoot.  Providing simple html code as I have done is one thing, but processing on the back end is a much larger project that also needs to take into consideration security.

If you are not familiar with a back end language, then it may be best to hire somebody. If you are technically inclined and want to learn to do this on your own, that is fine, but you should provide the next step which will be trying out some code in a language you are somewhat familiar with. You mentioned PowerShell. I am not well versed in PS but I think you may want to start here https://docs.microsoft.com/en-us/dotnet/api/system.net.webclient.uploadfile?redirectedfrom=MSDN&view=netframework-4.8#overloads. If this is for a web site (internal or external) you are typically not going to use PS for something like this, you will need to use C#/ASP.NET,  Node, PHP etc. to handle the file upload and save the file. Once uploaded, you can use PS to listen for a new file and continue processing but I think it makes more sense to continue in the server side language you started with.