Advertisement
Guest User

Untitled

a guest
Jun 27th, 2016
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 2.74 KB | None | 0 0
  1.  
  2. @{  
  3.    
  4.     var imagePath = "";
  5.     WebImage photo = null;
  6.     var FileName = "";
  7.    
  8.     if (IsPost)
  9.     {
  10.         photo = WebImage.GetImageFromRequest();
  11.         if (photo != null)
  12.         {
  13.             FileName = Path.GetFileName(photo.FileName);
  14.             imagePath = @"image\" + FileName;
  15.  
  16.             photo.Save(@"~\" + imagePath);
  17.         }
  18.     }
  19.  
  20.  
  21.  
  22.   if (Request["photoChoice"] != null)
  23.    {
  24.        
  25.          imagePath = @"image\" + Request["photoChoice"];
  26.          
  27.      
  28.     }
  29. }
  30. <!DOCTYPE html>
  31. <html>
  32. <head>
  33.     <title>Галерея изображений</title>
  34.     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  35.     <meta name="description" content="The description of my page" />
  36.     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  37.     <link rel="stylesheet" type="text/css" href="mystyle.css">
  38. </head>
  39. <body>
  40.     <img src="~/Images/logo.png"/>
  41.     <h1>Галерея</h1>
  42.  
  43.     <form style="line-height: 2.5;" action="~/ShowAll">
  44.         <button  type="submit">Просмотр галереи</button>
  45.        
  46.     </form>
  47.  
  48.     <form method="post" action="">
  49.         <div>
  50.             Выбор файла:
  51.             <select name="photoChoice">
  52.  
  53.                 @{
  54.                    <option selected disabled> Выберите:</option>
  55.                     DirectoryInfo files = new DirectoryInfo(Server.MapPath(@"~\image"));
  56.                    int i= 1;
  57.                    foreach (var f in files.GetFiles())
  58.                    {
  59.                     <option value="@f.Name"> Photo @i.ToString() - @f.Name</option>
  60.                        i++;
  61.                     }
  62.  
  63.                 }
  64.              
  65.             </select>
  66.             &nbsp;
  67.             <input type="submit" value="Выбрать" />
  68.         </div>
  69.         <div style="padding:10px;">
  70.             @if (imagePath != "")
  71.             {
  72.                 <img src="@imagePath" alt="Ошибка: здесь должно было быть изображение" width="300" />
  73.                 <br />
  74.                
  75.     <a href="@Html.AttributeEncode(imagePath)" target="_Self">
  76.         Открыть оригинал
  77.     </a>
  78.             }
  79.         </div>
  80.  
  81.     </form>
  82.  
  83.    
  84.     <form action="" method="post" enctype="multipart/form-data">
  85.         <fieldset>
  86.             <legend> Загрузить изображение </legend>
  87.             <label for="Image">Image</label>
  88.             <input type="file" name="Image" accept="image/*" />
  89.             <br />
  90.            <p> <input type="submit" value="Загрузить" /></p>
  91.         </fieldset>
  92.     </form>
  93.  
  94.    
  95.    
  96.     <div id="footer">
  97.         <center> &copy; , 2016</center>
  98.     </div>
  99.  
  100. </body>
  101. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement