Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Rename an Image in MVC Core2 Controller

$
0
0
<div class="container _full "> <div class="snippet-hidden" id="content"> <div itemtype="http://schema.org/Question" itemscope=""> <div class="inner-content clearfix"> <div id="mainbar" role="main" aria-label="question and answers"> <div class="question" id="question" data-questionid="49282575"> <div class="post-layout"> <div class="postcell post-layout--right"> <div class="post-text" itemprop="text">

how do I rename an image in an MVC core 2 controller.

The code below is not working and nothing is done.

string savelocation = path;
            string fileExtention = System.IO.Path.GetExtension(files[0].FileName);
            //creating filename to avoid file name conflicts.
            string NewName = id.ToString();// id is actually the Primary key
            //saving file in savedImage folder.
            var savePath = savelocation + NewName + fileExtention;


            string result2 = "/uploads/" + user + "/" + Path.GetFileName(savePath);

            var stream3 = new FileStream(NewName, FileMode.Create);
            files[0].CopyTo(stream3);




            stream3.Flush();
            stream3.Dispose();

</div> </div> </div> </div> </div> </div> </div> </div> </div>

Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>