Error when i upload file except txt ADODB.Stream error '800a0bbc' - asp-classic

error showing whenever I try to upload file except for txt, this error showing when I try upload jpeg file, there is no exception any specific file that can upload in the code, it should upload a jpeg file or pdf, but it showing error like this:
ADODB.Stream error '800a0bbc'
Write to file failed.
/ros/ROS/freeaspupload.asp, line 241
this is the freeaspupload code where the error came
Public Sub SaveParkir(path, prefixFile)
Dim streamFile, fileItem, i
if Right(path, 1) <> "\" then path = path & "\"
if not uploadedYet then Upload
i = 1
For Each fileItem In UploadedFiles.Items
Set streamFile = Server.CreateObject("ADODB.Stream")
streamFile.Type = 1
streamFile.Open
StreamRequest.Position=fileItem.Start
StreamRequest.CopyTo streamFile, fileItem.Length
streamFile.SaveToFile path & prefixFile & fileItem.FileName, 2
streamFile.close
Set streamFile = Nothing
fileItem.Path = path & prefixFile & fileItem.FileName
i = i + 1
'response.Write fileItem.Path
Next
'response.Write i
End Sub
what is the problem? how can i fix this? thanks in advance

Related

How to show window prompt for downloading excel file?

I have written code for exporting data to xlsx file. But i dont understand how to show window prompt for downloading that xlsx file at client end.
Here's my code:
Private Sub DataTableToExcel(ByVal tbl As DataTable)
Dim Excel As Object = CreateObject("Excel.Application")
Dim strFilename As String
Dim intCol, intRow As Integer
Dim strPath As String = "C:\"
If Excel Is Nothing Then
MsgBox("It appears that Excel is not installed on this machine. This operation requires MS Excel to be installed on this machine.", MsgBoxStyle.Critical)
Return
End If
Try
With Excel
.SheetsInNewWorkbook = 1
.Workbooks.Add()
.Worksheets(1).Select()
.cells(1, 1).value = "Complaint Detail Report" 'Heading of the excel file
.cells(1, 1).EntireRow.Font.Bold = True
Dim intI As Integer = 1
For intCol = 0 To tbl.Columns.Count - 1
.cells(2, intI).value = tbl.Columns(intCol).ColumnName
.cells(2, intI).EntireRow.Font.Bold = True
intI += 1
Next
intI = 3
Dim intK As Integer = 1
For intCol = 0 To tbl.Columns.Count - 1
intI = 3
For intRow = 0 To tbl.Rows.Count - 1
.Cells(intI, intK).Value = tbl.Rows(intRow).ItemArray(intCol)
intI += 1
Next
intK += 1
Next
If Mid$(strPath, strPath.Length, 1) <> "\" Then
strPath = strPath & "\"
End If
strFilename = strPath & "ComplaintDetail.xlsx"
.ActiveCell.Worksheet.SaveAs(strFilename)
End With
System.Runtime.InteropServices.Marshal.ReleaseComObject(Excel)
Excel = Nothing
MsgBox("Data's are exported to Excel Succesfully: Location: '" & strFilename & "'", MsgBoxStyle.Information)
' Response.AddHeader("content-disposition", "attachment;filename=ComplaintDetail.xlsx")
'Response.ContentType = "application/vnd.excel"
Catch ex As Exception
MsgBox(ex.Message)
End Try
Dim pro() As Process = System.Diagnostics.Process.GetProcessesByName("EXCEL")
For Each i As Process In pro
i.Kill()
Next
End Sub
Here I am saving .XLSX file directly to "C Drive".
Why I choose C Drive? : Because 99% of people have C: in there pc.
But I got some scenario where user don't allow access of their C drive or they don't give permission to write anything inside c drive.
That's why I am trying to add this window prompt where user will decide where to save that file. But i got some issue in above code.
Can you please help me to add window prompt in above code?
Save in the App_Data directory. You can find the absolute path with Server.MapPath("~/App_Data") This path is writeable by the application
Use Response.TransmitFile to make the file to be downloaded.
Try using something like a save file dialog (this can be added via the ui designer).
Then use:
If dialog.Show() = Windows.Forms.DialogResult.OK Then
strPath = dialog.FileName
End If

ADODB.Stream error '800a0bbc' Write to file failed

I've weird and strange error showing while I change hosting provider which is:
ADODB.Stream error '800a0bbc'
Write to file failed.
/cp/portal_upload.asp, line 63
I gave the needed permissions and it solve the update Access DB problem but file uploading still not fixed.
this is the code, thanks in advance:
Public Sub Save(path)
Dim streamFile, fileItem
if Right(path, 1) <> "\" then path = path & "\"
if not uploadedYet then Upload
For Each fileItem In UploadedFiles.Items
Set streamFile = Server.CreateObject("ADODB.Stream")
streamFile.Type = 1
streamFile.Open
StreamRequest.Position=fileItem.Start
StreamRequest.CopyTo streamFile, fileItem.Length
streamFile.SaveToFile path & fileItem.FileName, 2 'This is line 63
streamFile.close
Set streamFile = Nothing
fileItem.Path = path & fileItem.FileName
Next
End Sub
Firstly check if path & fileItem is a valid address?
If the folders is not created, create it.
Also, recheck your permissions. Have you given IUSR the permission of "Full Control"?

File Upload / download using vb.net

I'm trying to develop a website with File upload and download option using vb.net and asp.net with Visual Studio 2008. Can anyone help me about how can I provide the facility of uploading a file into the server and then a download link will be available for the common users to download the file from the server. Thanks in advance.
Use FileUpLoad control.
Here is a sample for uploading (in c#) :
http://www.c-sharpcorner.com/UploadFile/mahesh/FileUpload10092005172118PM/FileUpload.aspx
You can use asp:FileUpload control to upload file to your server, a location with permission to write file
FileUpload control overview
FileUpload example
It's as simple as putting the control in your .aspx file
<asp:FileUpload runat="server" ID="MyFileUpload" />
Codebehind
If (MyFileUpload.HasFile) Then
MyFileUpload.SaveAs('the full path to directory ' & filename)
End If
You can store the file description in database with their path, retrieve this on your page and display to user
You can also browse your directory and list the files on your page
Dim FileToCopy As String
FileToCopy = "F:\fd_demo_limits.swf"
Dim filenameTest = System.IO.Path.GetFileName(FileToCopy)
Dim path As String = "E:\"
Dim filename As String = "communicate.png"
Dim file_ As New System.IO.FileInfo(path + filename)
Dim file_ContentLength As String = "900000" ' check file Length file_.Length = 833740
If (file_.Length > file_ContentLength) Then
MsgBox("file length is large")
Exit Sub
End If
Dim allow_send_pic() As String = {".jpg", ".png", ".gif", "ico", ".png"}
Dim Extension As String = System.IO.Path.GetExtension(filename)
If Array.IndexOf(allow_send_pic, Extension.ToLower()) = -1 Then
MsgBox("File extension not valid")
Exit Sub
End If
If System.IO.File.Exists(FileToCopy) = True Then
While (System.IO.File.Exists(path + filename))
filename = "Copy of " + filename
End While
System.IO.File.Copy(FileToCopy, path + filename)
MsgBox("File Copied")
End If

What's the correct way to specify file path in VBscript?

New to VBscript and spending way too much time trying to find the right way to open a file for reading. Whatever I've tried I always get "Path not found" error.
This is the real path to my files:
D:\InetPub\vhosts\lamardesigngroup.com\httpdocs\
The file that I am trying to run is:
D:\InetPub\vhosts\lamardesigngroup.com\httpdocs\ifp\files.asp
and I want to read this file:
D:\InetPub\vhosts\lamardesigngroup.com\httpdocs\ifp\css\style.css
Here is the code:
Dim objFSO, strTextFile, strData, strLine, arrLines
CONST ForReading = 1
'name of the text file
strTextFile = "//css/style.css"
'Create a File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Open the text file - strData now contains the whole file
strData = objFSO.OpenTextFile(strTextFile,ForReading).ReadAll
'Split the text file into lines
arrLines = Split(strData,vbCrLf)
'Step through the lines
For Each strLine in arrLines
response.write(strLine & "<br>")
Next
'Cleanup
Set objFSO = Nothing
and I get "12|800a004c|Path_not_found 80"
I've also tried
strTextFile = "D:\InetPub\vhosts\lamardesigngroup.com\httpdocs\ifp\css\style.css"
' and
strTextFile = "\\css\style.css"
strTextFile = "css\style.css"
strTextFile = "css/style.css"
' and many other combinations
I'm obviously lost...
Morning Harley,
Give this a try:
strTextFile = server.MapPath("css/style.css")
It should result in recognizing your specific server location. I ran into this problem trying to get some vbscript file upload code to work. It should start from the folder your page is working in and go from there.

How to upload image with NicEdit and classic asp

I would like to use nicedit image upload with classic asp. By default Nicedit uploads images to ImageShack, but I would like to send images to my server. However I'm having trouble to adapt some features of the original PHP script to classic asp. I found this script that uploads the image and returns the image info in javascript format and generates a progress bar.
<script>
try{
top.nicUploadButton.statusCb({'done':1,'url':'$link','width':30});
}
catch(e) {
alert(e.message);
}
</script>
PHP has built-in functions that provide a progress bar and I have difficulties setting up a progress bar in vbscript.
Could someone guide me on what should be implemented so that the basic functions of this script remain in the asp version? Thanks.
==UPDATE==
I made the upload script that is working well, but I need help to make the progress bar. I usually use the jQuery progress bar inside a loop but would like to help in order to make it work during this upload process.
<%
Server.ScriptTimeout = 26000
UplMaxSize = 1048576
sExtL = "jpg,jpeg,png,gif,bmp"
Set Upload = Server.CreateObject("Persits.Upload")
Upload.OverwriteFiles = True
Upload.SetMaxSize UplMaxSize, True
nCount = Upload.Save
If nCount > 0 Then
Set File = Upload.Files(1)
sFileName = File.FileName
sWidth = File.ImageWidth
If Err.Number = 8 Then
Set uplresult = jsObject()
uplresult("error") = "O tamanho do arquivo excedeu o limite!"
uplresult.Flush ' estampa json
Response.End()
End If
If Not File Is Nothing Then
' Save the file to the file system
sPath = Server.MapPath(".\public\upimages")
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
sExt = oFSO.GetExtensionName(sPath & sFileName)
If Not (InStr(sExtL,sExt) > 0) Then
Set uplresult = jsObject()
uplresult("error") = "Extensão de arquivo inválida!"
uplresult.Flush ' estampa json
Response.End()
End If
File.SaveAs sPath & "\" & sFileName
Response.Write("<script>try {top.nicUploadButton.statusCb({'done':1,'url':'/blog/public/upimages/" & sFileName & "','width':" & sWidth & "});} catch(e) {alert(e.message);}</script>")
End If
End If
%>

Resources