FTP to WinHost

Discussion in 'Site Programming, Development and Design' started by binaryanimation, Aug 26, 2010.

  1. I successfully can write to my database; title date code etc.
    I can also writerelated image to my domain and via IIS, i can see the image in the directory.
    But the image appears blank when i run the page.

    Please help

    Thanks in advance.
    www.binaryanimation.com



    dr[1] = title.Text;

    //IMAGE

    byte[] byteTest = new byte[img.PostedFile.ContentLength];

    using (Stream streamImg = img.PostedFile.InputStream)
    {


    streamImg.Read(byteTest, 0, img.PostedFile.ContentLength + 1);
    }

    FtpWebRequest ftpwebrequestimg = (FtpWebRequest)FtpWebRequest.Create("ftp://" + ConfigurationSettings.AppSettings["ftpSitePic"] + "/" + img.PostedFile.FileName);
    ftpwebrequestimg.Credentials = new NetworkCredential(ConfigurationSettings.AppSettings["ftpSiteUsername"], ConfigurationSettings.AppSettings["ftpSitePassword"]);
    ftpwebrequestimg.UseBinary = true;
    ftpwebrequestimg.Method = WebRequestMethods.Ftp.UploadFile;

    using (Stream ftpUploadImg = ftpwebrequestimg.GetRequestStream())
    {
    ftpUploadImg.Write(byteTest, 0, img.PostedFile.ContentLength);
    }

    dr[2] = "../../" + img.PostedFile.FileName;
     
  2. Ray

    Ray

    I don't see any broken images on the page. Did you fix the problem?
     
  3. Ray

    Ray

    I'm still not sure exactly what the problem is.

    Like I said I don't see any broken links.

    I think you are trying to describe two problems that may not be related to each other.

    The first problem is...

    But the image appears blank when i run the page.

    The second problem is...

    I tried uploading via the website itself and failed.

    This seems to be a FTP problem.

    Lets try not to mix and confuse both the issues as being the same.

    Lets focus on your broken links broken image problem first. What I will need from you is a way for me to replicate the broken links you are referring to on my end. I will need you to outline a detailed instructions on how I can see these broken images/links on my computer.
     
  4. Winhost Client Login

    Username: Winhost
    Passwork: ray

    Please login and access the backend of my test site Using addPicture.

    I can only upload to Winhost while testing on my computer and the result is testFTP.png which as u can c is of no use.


    Regards
     
    Last edited by a moderator: Oct 14, 2015
  5. Ray

    Ray

    I'm guessing you are storing the images in the databases, right?

    Can you upload an image other then .png?
     
  6. Images are not stored in the database.
    That's why I use webrequest.
    I wish To upload to images direct to my site directory and store related details in the database.

    I can see the images .png .gif etc via iis, confirming that the webrequest connected to my site, but since I have no way no way of actually see if the images have been distorted, I can't see where the problem ls from.

    Thanks
     
  7. Ray

    Ray

    This is hard to say because I'm really not familiar with your coding. I'm sure their is more to it then typing the correct path. I can only suggest that you setup a simple web application in a subfolder and test out your feature there. It is easier to troubleshoot/debug coding when it is scaled down to a more simpler version. If you are passing any variables to determine the path, maybe you may want to bypass that for now and hard code the path directly. I have a sinking suspension that it is the path and if you are some sort of variables to create it, it maybe that the path is not getting generated correctly.
     
  8. I think Ray is right. This seems pretty simple - if you can view the image but the image breaks in a page, the image reference in the page is broken. Meaning the path to the image that you're entering into the database is incorrect somehow.

    But I don't know - you keep saying you can see the image via IIS, and I'm not sure what you mean by that. If you can see it in browser, your problem is the path.
     

Share This Page