CFF KB - Carrz-Fox-Fire Promotions Knowledge Base
CFF KB is all about 1 thing: The Sharing of Knowledge and the Power we gain from it.Knowledge Base
- Breadrumbs:
A generic error occurred in GDI+
- Article ID:
6249 - Date Created
Saturday, June 11, 2022 - Last Updated
Saturday, June 11, 2022 - This Article Has been Viewed
397 times - Short Desc
You will receive the following error when using the FileUpload and resizeImage function in asp.net to upload images without a folder. A generic error occurred in GDI+ - Details
When uploading an image with ASP.NET, you either need to create the folders manually before running the script or make the folders in code. - Recreate Issue
Scenario #1
The location to store the uploaded image has yet to be created. - Resolve Issue
Scenario #1
For this one, we will create different-sized images for each uploaded image.
The script that threw the error<%
Dim ImageToSave As System.Drawing.Image = resizeImage(System.Drawing.Image.FromStream(postedFile.InputStream), New Size(130, 110))
ImageToSave.Save(Context.Server.MapPath(Path.Combine(savethPath, getFile.Insert(getFile.LastIndexOf("."c), ""))), ImageFormat.Jpeg) '<< This line
%>
The error is due to the Directory not being created first. Therefore, the script cannot upload the image to that location without the created Directory.
To create the Directory.<%
Dim subPath As String = Path.Combine(theImageFolder, thPath)
If Not Directory.Exists(subPath) Then
Directory.CreateDirectory(subPath)
End If
%>
Share With Friends (Updated 6-8-2010)
Recent Articles
All Topics
- Coming Soon - Knowledge Exchange
Trending Articles
- Microsoft VBScript runtime error '800a0046' Permission denied FileSystemObject 24695
- Microsoft OLE DB Provider for SQL Server error '80040e57' String or binary data would be truncated. or The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data. 21297
- ADODB.Parameters error '800a0e7c' Parameter object is improperly defined 19544
- After Effects warning: Audio conforming failed for the following file .cfa. Perhaps due to disk space 17785
- The backup set holds a backup of a database other than the existing 16825