Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
File upload 在戈达迪发布.net网站_File Upload_Permissions_Publishing - Fatal编程技术网

File upload 在戈达迪发布.net网站

File upload 在戈达迪发布.net网站,file-upload,permissions,publishing,File Upload,Permissions,Publishing,我正在使用microsoft visual studio构建和发布我的网站。我可以通过ftp发布到我的主机godaddy 我的网站在本地运行良好,直到我发布到网上 我在尝试加载照片时遇到此错误。是否需要将文件夹设置为读写执行 “/”应用程序中出现服务器错误。 对路径“D:\Hosting\8722453\html\Pictures\1bd71b0f-bd55-48a7-9368-2e8faadf5830.jpg”的访问被拒绝 我相信问题出在这个代码块上 if (FileUpload1.HasFi

我正在使用microsoft visual studio构建和发布我的网站。我可以通过ftp发布到我的主机godaddy

我的网站在本地运行良好,直到我发布到网上

我在尝试加载照片时遇到此错误。是否需要将文件夹设置为读写执行

“/”应用程序中出现服务器错误。 对路径“D:\Hosting\8722453\html\Pictures\1bd71b0f-bd55-48a7-9368-2e8faadf5830.jpg”的访问被拒绝

我相信问题出在这个代码块上

if (FileUpload1.HasFile)
                try
                {
                    var FileExtension = Path.GetExtension(FileUpload1.PostedFile.FileName);
                    //FileUpload1.PostedFile.ContentType == 
                    if (FileUpload1.PostedFile.ContentType.ToLower() == "image/jpg" ||
                    FileUpload1.PostedFile.ContentType.ToLower() == "image/jpeg" ||
                    FileUpload1.PostedFile.ContentType.ToLower() == "image/pjpeg" ||
                    FileUpload1.PostedFile.ContentType.ToLower() == "image/gif" ||
                    FileUpload1.PostedFile.ContentType.ToLower() == "image/x-png" ||
                    FileUpload1.PostedFile.ContentType.ToLower() == "image/png")
                    {
                        var Myguid = Guid.NewGuid().ToString("N");

                        var newName = Guid.NewGuid() + FileExtension;
                        //Map path to folder
                        string realpath = Server.MapPath("Pictures\\") + newName;
                        //Where jays converter will store the new image.
                        string temppath = Server.MapPath("Pictures\\");
                        string newpath = Server.MapPath("Images\\");

                        FileUpload1.SaveAs(realpath);

                        Label1.Text = "File name: " +
                             FileUpload1.PostedFile.FileName + "<br>" +

                             FileUpload1.PostedFile.ContentLength + " kb<br>" +
                             "Content type: " +
                             FileUpload1.PostedFile.ContentType;


                        InsertMembers insert = new InsertMembers();
                        int age = Int32.Parse(txtAge.Text);
                        insert.InsertNewMember(txtEmail.Text, Myguid, txtName.Text, txtCity.Text, txtState.Text, txtDescription.Text, age, gender);


                        //Get Member Id to Insert into Pictures table
                        GetMemberInfo GetID = new GetMemberInfo();
                        int UMemberId = GetID.GetMemberId(Myguid);
                        Displayme.Text = newName.ToString();

                        //Now that i have member Id Lets insert new picture into picture table
                        Picture InsertnewPictures = new Picture();
                        int insertpics = InsertnewPictures.InserNewPicture(UMemberId, newName, 0);

                        PhotoUtils.JpegConvertor mynewvar = new PhotoUtils.JpegConvertor(temppath, newpath, newName, 300, 400, false);
                        //PhotoUtils.JpegConvertor mynewvare = new PhotoUtils.JpegConvertor()
                    }
                    else
                    {
                        Displayme.Text = "You can only upload jpg's png's or bmp images.";
                    }
                }
                catch (Exception ex)
                {
                    //Handle the error
                    throw ex;
                }

图片和图像目录是否在虚拟目录中?如果不是,这是一个问题。接下来要检查的是,用户可以读取和写入这些目录。另外需要注意的是,如果在给定的时间段内更改了足够多的文件,IIS进程将重新启动网站或应用程序池,我不确定它们是否在同一时间段内


这可以在IIS中配置,但我不确定。我会尽量限制文件写入的次数,并处理内存中的图像,只将最终结果写入磁盘。另一种选择是将图像存储在数据库中。正在删除在虚拟目录下读取/写入文件的需要。

是否确实可以访问上面显示的路径?我检查了读取和写入权限,似乎解决了此问题,谢谢。