我不是一个程序员,所以对于我可能对这个问题缺乏理解,我深表歉意。我一直在挖掘所有代码,但我无法弄清楚这一点。该站点是一个asp.net 站点。编译时没有错误,除了关于高度的错误,这不适用。我使用的是共享主机,所以我无法访问系统文件。
客户将图像上传到我们的网站,以便我们处理和打印他们订购的任何产品。在他们点击继续付款按钮之前,图像不会出现在服务器上的任何位置。我在验证文件夹大小之前和之后都下载了整个站点。
图像在实际存储为 .jpg 之前临时存储在哪里?
</asp:UpdatePanel>
<asp:Button CssClass="Buttons" ID="Button1"
style="font-weight: bold; color: white; background-color: #336699;"
runat="server" OnClick="AddToCartButton_Click"
Text="Upload Image and Add To Cart"
CommandArgument="ObjectDataSourceEventArgs" />
<div style="width:800px">
<br />
Larger files may take a minute or two to upload
<asp:Label ID="lblLimitReached" runat="server"
Visible="false" STYLE="color:Red" Text="">
</asp:Label>
</div>
<br /><hr /><br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BorderStyle="Solid"
Caption="Shopping Cart" CellPadding="4" DataSourceID="ShoppingCartDataSource"
ForeColor="#333333" GridLines="Vertical" CaptionAlign="Top" OnRowDeleting="GridView1_RowDeleting">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:BoundField DataField="OriginalImageName" HeaderText="Image" SortExpression="OriginalImageName" />
<asp:BoundField DataField="SizePrice" HeaderText="Size / Price" SortExpression="SizePrice" />
<asp:BoundField DataField="Quantity" HeaderText="Quantity" SortExpression="Quantity" />
<asp:BoundField DataField="MountedString" HeaderText="Mounted" SortExpression="Mounted" />
<asp:BoundField DataField="DigitalString" HeaderText="Digital Frame" SortExpression="DigitalFrame" />
<asp:BoundField DataField="BWString" HeaderText="Black & White" SortExpression="BlackAndWhite" />
<asp:BoundField DataField="PriceString" HeaderText="Price" ReadOnly="True" SortExpression="PriceString" />
<asp:CommandField ButtonType="Button" ShowDeleteButton="True" />
</Columns>
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:ObjectDataSource ID="ShoppingCartDataSource" runat="server" DataObjectTypeName="ImageInfo"
DeleteMethod="DeleteData" InsertMethod="InsertData" SelectMethod="SelectData"
TypeName="ImageInfoCollection" UpdateMethod="UpdateData" OnObjectCreating="ShoppingCartDataSource_ObjectCreating" ></asp:ObjectDataSource>
<hr /><br />
<asp:Label ID="TotalPriceLabel" runat="server" style="display:inline" Text="Current total: $0.00" Width="162px"></asp:Label>
<br />
<asp:Button CssClass="Buttons" ID="CheckOutButton" runat="server"
Text="Go To Check Out" CausesValidation="False"
OnClick="PlaceOrderButton_Click"
style="font-weight: bold; color: white; background-color: #336699;"
Visible="False" /><br />
<asp:Label ID="FreeShipLabel" runat="server" ForeColor="#FF0033"></asp:Label><br />
<asp:XmlDataSource ID="ImageSizeDataSource" runat="server" DataFile="~/App_Data/ImageSizeData.xml"></asp:XmlDataSource>
<asp:RequiredFieldValidator ID="ImagePathValidator" runat="server" ControlToValidate="FileUpload1"
ErrorMessage="Please select an image to upload." Display="None"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="FileUploadTypeValidator" runat="server" ControlToValidate="FileUpload1"
Display="None" ErrorMessage="Please upload only files of type jpg (or jpeg)."
ValidationExpression="(.*\.jpg)|(.*\.jpeg)|(.*\.JPG)|(.*\.JPEG)"></asp:RegularExpressionValidator>
<asp:RequiredFieldValidator ID="ImageSizeValidator" runat="server" ControlToValidate="SizeDropDownList"
ErrorMessage="Please select an image size." Display="None"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="QuantityValidator" runat="server" ControlToValidate="QuantityTextBox"
ErrorMessage="Please select image quantity." Display="None"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="QuantityExpressionValidator" runat="server" ControlToValidate="QuantityTextBox"
Display="None" ErrorMessage="Invalid quantity: please choose 1 to 999." ValidationExpression="^([1-9]|[1-9][0-9]|[1-9][0-9][0-9])$"></asp:RegularExpressionValidator>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" DisplayMode="List"
HeaderText="Something is missing:" Height="40px" ShowMessageBox="True"
ShowSummary="False" Width="179px" />
<br />
<div style="width:800px">
<uc3:Footer ID="Footer1" runat="server" />
</div>
</form>
这是buynow.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Xml;
using System.Drawing;
public partial class BuyNow : System.Web.UI.Page
{
const string DFText = "Choose a Digital Frame.";
/// <summary>
/// Page_Load
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
Page PP = Page.PreviousPage as ASP.home_aspx;
if (!IsPostBack)
{
ImageInfoCollection ImageInfo = new ImageInfoCollection();
Session["ImageInfoCollection"] = ImageInfo;
ResetDefaults();
FreeShipLabel.Text = "";
FileUpload1.Focus();
}
}
/// <summary>
/// AddToCartButton_Click
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void AddToCartButton_Click(object sender, EventArgs e)
{
ImageInfoCollection Images = (ImageInfoCollection)Session["ImageInfoCollection"];
if (Images == null) {
Session["SessionError"] = "No Images on BuyNow->AddToCartButton_Click";
Response.Redirect("Error.aspx");
}
if (Images.Count >= 20)
{
lblLimitReached.Text = "Only 20 Images allowed per order...Please place another order";
lblLimitReached.Visible = true;
return;
}
/// BUG: need to figure out how to handle the Back Button case
if (DigitalFramesCheckBox.Checked && (DigitalFrameLabel.Text == "" || DigitalFrameLabel.Text == DFText))
return;
ImageInfo Image = CreateImageInfoFromPage();
if (Image == null)
return;
Images.InsertData(Image);
Session["ImageInfoCollection"] = Images;
ShoppingCartDataSource.Select();
GridView1.DataBind(); // update the GridView shopping cart
TotalPriceLabel.Text = "Current Total: " + CalculateCartPrice(Images);
ResetDefaults();
if (Images.FreeShipping())
FreeShipLabel.Text = "Order Qualifies for Free Shipping.";
else
FreeShipLabel.Text = "";
if (Images.Count > 0)
CheckOutButton.Visible = true;
}
/// <summary>
/// ShoppingCartDataSource_ObjectCreating
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ShoppingCartDataSource_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
{
// Code that runs when a new session is started
ImageInfoCollection Images = (ImageInfoCollection)Session["ImageInfoCollection"];
if (Images == null) {
Session["SessionError"] = "No Images on ShoppingCartDataSource_ObjectCreating";
Response.Redirect("Error.aspx");
}
e.ObjectInstance = Images;
}
/// <summary>
/// GridView1_RowDeleting
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
ImageInfoCollection Images = (ImageInfoCollection)Session["ImageInfoCollection"];
if (Images == null)
return;
Images.DeleteData(e.RowIndex);
Session["ImageInfoCollection"] = Images;
TotalPriceLabel.Text = "Current Total: " + CalculateCartPrice(Images);
if (Images.FreeShipping())
FreeShipLabel.Text = "Order Qualifies for Free Shipping.";
else
FreeShipLabel.Text = "";
if (Images.Count == 0)
CheckOutButton.Visible = false;
}
/// <summary>
/// SizeDropDownList_SelectedIndexChanged
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void SizeDropDownList_SelectedIndexChanged(object sender, EventArgs e)
{
// read the xml file to determine image size attributes
int index = SizeDropDownList.SelectedIndex;
ImageXmlAttributes Attrs = new ImageXmlAttributes(ImageSizeDataSource);
Attrs.LoadByIndex(index);
// translate the attributes into controls for the page
// QuantityListBox.Text = Convert.ToString(Attrs.Quantity);
if (Attrs.MountingAvailable) {
MountingCheckBox.Enabled = true;
MountingPriceLabel.Enabled = true;
MountingPriceLabel.Text = "$" + Convert.ToString(Attrs.MountingPrice);
}
else {
MountingCheckBox.Enabled = false;
MountingCheckBox.Checked = false;
MountingPriceLabel.Enabled = false;
MountingPriceLabel.Text = "";
}
if (Attrs.DigitalAvailable) {
DigitalFramesCheckBox.Enabled = true;
DigitalFrameLabel.Text = "";
}
else {
DigitalFramesCheckBox.Enabled = false;
DigitalFramesCheckBox.Checked = false;
DigitalFramePanel.Visible = false;
DigitalFrameLabel.Text = "";
}
if (Attrs.BWAvailable)
BlackAndWhiteCheckBox.Enabled = true;
else {
BlackAndWhiteCheckBox.Enabled = false;
BlackAndWhiteCheckBox.Checked = false;
}
CardPanel.Visible = false;
if ((SizeDropDownList.Text == "DLCCU1") || (SizeDropDownList.Text == "DLCCU2") || (SizeDropDownList.Text == "DLCCU3"))
{
CardPanel.Visible = true;
}
}
protected void MountingCheckBox_CheckedChanged(object sender, EventArgs e)
{
if (!MountingCheckBox.Checked)
MountingPriceLabel.Text = "";
else {
// read the xml file to determine image size attributes
int index = SizeDropDownList.SelectedIndex;
ImageXmlAttributes Attrs = new ImageXmlAttributes(ImageSizeDataSource);
Attrs.LoadByIndex(index);
MountingPriceLabel.Text = "$" + Convert.ToString(Attrs.MountingPrice);
}
}
/// <summary>
/// PlaceOrderButton_Click
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void PlaceOrderButton_Click(object sender, EventArgs e)
{
Response.Redirect("~/CustomerInfo.aspx");
}
/// <summary>
/// CreateImageFromPage
/// </summary>
/// <returns></returns>
private ImageInfo CreateImageInfoFromPage()
{
ImageInfo Image = new ImageInfo( ImageSizeDataSource );
Image.MyFileUpload = FileUpload1;
Image.OriginalImageName = FileUpload1.FileName;
Image.Mounted = MountingCheckBox.Checked;
Image.BlackAndWhite = BlackAndWhiteCheckBox.Checked;
Image.DigitalFrame = DigitalFramesCheckBox.Checked;
Image.DigitalFrameID = DigitalFrameLabel.Text;
Image.Quantity = Convert.ToInt32(QuantityTextBox.Text);
Image.LoadAttributes(SizeDropDownList.SelectedIndex);
return Image;
}
/// <summary>
/// ResetDefaults
/// </summary>
private void ResetDefaults()
{
SizeDropDownList.ClearSelection();
QuantityTextBox.Text = "1";
MountingCheckBox.Checked = false;
MountingPriceLabel.Text = "";
MountingCheckBox.Enabled = true;
BlackAndWhiteCheckBox.Checked = false;
BlackAndWhiteCheckBox.Enabled = true;
DigitalFramesCheckBox.Checked = false;
DigitalFramesCheckBox.Enabled = true;
DigitalFramePanel.Visible = false;
CardPanel.Visible = false;
CardPanel.Visible = false;
DigitalFrameLabel.Text = "";
DigitalFrameLabel.ForeColor = Color.Black;
}
/// <summary>
/// CalculateCartPrice
/// </summary>
/// <param name="Images"></param>
/// <returns></returns>
private static string CalculateCartPrice(ImageInfoCollection Images)
{
return Images.GetTotalPriceString();
}
protected void DigitalFramesCheckBox_CheckedChanged(object sender, EventArgs e)
{
TurnOffAllRadioButtons();
if (DigitalFramesCheckBox.Checked == true) {
DigitalFramePanel.Visible = true;
DigitalFrameLabel.Text = DFText;
DigitalFrameLabel.ForeColor = Color.Red;
SizeDropDownList.SelectedValue = "DL20U";
BlackAndWhiteCheckBox.Checked = false;
BlackAndWhiteCheckBox.Enabled = false;
}
else {
DigitalFramePanel.Visible = false;
DigitalFrameLabel.ForeColor = Color.Black;
DigitalFrameLabel.Text = "";
SizeDropDownList.SelectedValue = "";
BlackAndWhiteCheckBox.Checked = false;
BlackAndWhiteCheckBox.Enabled = true;
}
}
protected void RadioButtonF1_CheckedChanged(object sender, EventArgs e)
{
SelectRadioButton(RadioButtonF1, e);
}
protected void RadioButtonF2_CheckedChanged(object sender, EventArgs e)
{
SelectRadioButton(RadioButtonF2, e);
}
protected void RadioButtonF3_CheckedChanged(object sender, EventArgs e)
{
SelectRadioButton(RadioButtonF3, e);
}
protected void RadioButtonF4_CheckedChanged(object sender, EventArgs e)
{
SelectRadioButton(RadioButtonF4, e);
}
protected void RadioButtonF5_CheckedChanged(object sender, EventArgs e)
{
SelectRadioButton(RadioButtonF5, e);
}
protected void RadioButtonF6_CheckedChanged(object sender, EventArgs e)
{
SelectRadioButton(RadioButtonF6, e);
}
protected void RadioButtonF7_CheckedChanged(object sender, EventArgs e)
{
SelectRadioButton(RadioButtonF7, e);
}
protected void RadioButtonF8_CheckedChanged(object sender, EventArgs e)
{
SelectRadioButton(RadioButtonF8, e);
}
protected void RadioButtonF9_CheckedChanged(object sender, EventArgs e)
{
SelectRadioButton(RadioButtonF9, e);
}
protected void RadioButtonF13_CheckedChanged(object sender, EventArgs e)
{
SelectRadioButton(RadioButtonF13, e);
}
protected void RadioButton15_CheckedChanged(object sender, EventArgs e)
{
SelectRadioButton(RadioButtonF15, e);
}
protected void RadioButtonF16_CheckedChanged(object sender, EventArgs e)
{
SelectRadioButton(RadioButtonF16, e);
}
protected void RadioButtonF17_CheckedChanged(object sender, EventArgs e)
{
SelectRadioButton(RadioButtonF17, e);
}
protected void RadioButtonF18_CheckedChanged(object sender, EventArgs e)
{
SelectRadioButton(RadioButtonF18, e);
}
private void SelectRadioButton(RadioButton RB, EventArgs e)
{
TurnOffAllRadioButtons();
RB.Checked = true;
DigitalFrameLabel.Text = RB.ToolTip;
DigitalFrameLabel.ForeColor = Color.Black;
}
private void TurnOffAllRadioButtons()
{
RadioButtonF1.Checked = false;
RadioButtonF2.Checked = false;
RadioButtonF3.Checked = false;
RadioButtonF4.Checked = false;
RadioButtonF5.Checked = false;
RadioButtonF6.Checked = false;
RadioButtonF7.Checked = false;
RadioButtonF8.Checked = false;
RadioButtonF9.Checked = false;
RadioButtonF1.Checked = false;
RadioButtonF13.Checked = false;
RadioButtonF15.Checked = false;
RadioButtonF16.Checked = false;
RadioButtonF17.Checked = false;
RadioButtonF18.Checked = false;
}
protected void BlackAndWhiteCheckBox_CheckedChanged(object sender, EventArgs e)
{
if (BlackAndWhiteCheckBox.Checked) {
DigitalFramesCheckBox.Checked = false;
DigitalFramesCheckBox.Enabled = false;
}
else {
if ((SizeDropDownList.SelectedValue == "DL20U") || (SizeDropDownList.SelectedValue == ""))
{
DigitalFramesCheckBox.Enabled = true;
DigitalFramesCheckBox.Checked = false;
}
}
}
}