• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:

  • You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
  • You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
  • If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Previously on "I need a repository where people can dropfiles...."

Collapse

  • woohoo
    replied
    I would probably knock something up but not sure of your requirements. Once the files are uploaded do you want the user to see them, delete them etc.

    Anyway, I've been using Dropzone.js for drag and drop file uploads.

    If you are using ASP.NET MVC then just make reference to the relevant dropzone css/js.


    Add drop zone to the page for example

    Code:
                    <div id="dropzone">
                        <form action="@Url.Action("Upload", "ControllerNameHere")" class="dropzone dz-clickable" id="demoUpload" style="border: 2px dashed #816bb1">
                       
                            @Html.EditorFor(model => model.TemporaryId)
                            <div class="dz-message">
                                Drop files here or click to upload.<br />
    
                            </div>
    
                        </form>
                    </div>
    Then in the upload controller add a method to handle the files that are being posted for example the method below creates a folder using a guid. That's because it's a temp holding place for the files, but you could just use a user id or put everything in the temp/upload folder.

    Code:
            [HttpPost]
            public ActionResult Upload(string temporaryId)
            {
                try
                {
                    //use the temp id to create a folder structure for the uploaded images.
                    foreach (string fileName in Request.Files)
                    {
                        var file = Request.Files[fileName];
                        //Save file content goes here
                        //name = file.FileName;
                        if (file != null && file.ContentLength > 0)
                        {
    
                            var originalDirectory = new DirectoryInfo(string.Format("{0}\\temp\\upload", Server.MapPath("~")));
                            var pathString = Path.Combine(originalDirectory.ToString(), temporaryId);
    
                            if (!Directory.Exists(pathString))
                                Directory.CreateDirectory(pathString);
    
                            var path = string.Format("{0}\\{1}", pathString, file.FileName);
                            file.SaveAs(path);
                        }
    
                    }
                }
                catch (Exception exception)
                {
                    log.Error("Error uploading files " + exception);
                    return Json(new { success = "False" });
                }
    
                return Json(new { success = "True" });
            }
    It's worth saying this example automatically uploads the files when they are dropped on the control but you can configure to do on a button etc.

    Leave a comment:


  • unixman
    replied
    I use Owncloud on a small server at home. Not a Raspberry Pi but similar.

    Leave a comment:


  • SimonMac
    started a topic I need a repository where people can dropfiles....

    I need a repository where people can dropfiles....

    I need something where I can drop files into a repository from a webpage, I have an Azure account that I am not using so if its Windows based that's better.

    Whats the easiest way to do this? Anyone know an EFT type app?

Working...
X