Search code examples
asp.netasp.net-mvc-3file-uploadflickr

String.Empty as DirectoryName of HttpPostedFileBase


I have a controller with action:

[HttpPost]
        public ActionResult Add(Question container, HttpPostedFileBase file)
        {

            if (file != null && file.ContentLength > 0)
            {
                var clientPath=Path.GetDirectoryName(file.FileName);

and clientpath is "".

I need this because I don't want to save file at my server, but right away sending it to flickr

        string photoId = flickr.UploadPicture(clientPath, title, description, "", uploadAsPublic, false, false);

How can I get path of client file?

I'm using FlickrNet library btw.


Solution

  • To send the file directly without first saving it on the server, just use the overloaded method:

    string photoId = flickr.UploadPicture(file.InputStream, title, description, "", uploadAsPublic, false, false);