Ejemplo n.º 1
0
        // POST api/FileUpload
        public async Task <string> Post()
        {
            string result = "File not Uploaded";

            // Check if the request contains multipart/form-data.
            if (!Request.Content.IsMimeMultipartContent("form-data"))
            {
                return(result);
            }

            try
            {
                string BasePath    = System.Configuration.ConfigurationManager.AppSettings["basePath"];
                string MovieImages = System.Configuration.ConfigurationManager.AppSettings["MovieImages"];
                var    provider    = new PhotoMultipartFormDataStreamProvider(BasePath + MovieImages);
                await Request.Content.ReadAsMultipartAsync(provider);
            }
            catch (Exception ex)
            {
                return(result);
            }

            result = "File Uploaded Successfully";
            return(result);
        }
Ejemplo n.º 2
0
        // POST api/FileUpload
        public async Task <string> Post()
        {
            string result = "File not Uploaded";

            // Check if the request contains multipart/form-data.
            if (!Request.Content.IsMimeMultipartContent("form-data"))
            {
                return(result);
            }

            try
            {
                var provider = new PhotoMultipartFormDataStreamProvider(@"E:\SinglePageApplication\MyMovies\MovieImages");
                await Request.Content.ReadAsMultipartAsync(provider);
            }
            catch (Exception ex)
            {
                return(result);
            }

            result = "File Uploaded Successfully";
            return(result);
        }