Discuss ShadowUploader - uploading whole directory in the ASP Development forum on ASP Free. ShadowUploader - uploading whole directory ASP Development forum discussing ASP related topics including coding practices, ASP tips, and more. Active Server Pages (ASP) enables you to empower your HTML pages dynamically with robust scripting options.
ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month!
Receive the tools necessary to be the rock star of your field. Our 12-month program teaches you the evolving world of multi-channel marketing as well as the complex issues and opportunities found in the industry.
Web development can be a daunting task, even for specialists. There is a lot of information to absorb and a lot of technologies to learn in order to manage a superior website. When trying to learn the ropes, developers need a reliable source to introduce new ideas that can be easily implemented. When working on large projects, even web veterans may run into a technology or an aspect of a technology that they are unfamiliar with.
Hi wizard,
im looking into having a whole directory uploaded i cant do it threw the form cause i can only chose one file at a time and it would take for ever to upload 100 pictures.
I was thinking i can make a directory script with some checkbox's beside every folder and subfolder, users can then choose a folder then click on upload. the upload should not be so hard i can simply put each file in the folder into a hidden form and then submit it.
the problem i think i may have is searching the users computer to creat the directory.
If this is not possible i was thinking of maybe haveing user zip entire photo album and then have a script unzip it on the server.
any ideas how i should go about?
__________________
Mark
If you found a post particularly helpful, show your appreciation by clicking the "scales" icon in the bar just above the post, at the right hand side.
Last edited by Shadow Wizard : June 13th, 2006 at 08:15 AM.
Posts: 31,109
Time spent in forums: 3 Months 3 Weeks 2 Days 20 h 18 m 8 sec
Reputation Power: 2919
it's not possible and must not be possible. we must not have access to the user's
computer, otherwise think how easy it would be to write viruses!!
the only way, is writing activeX control (in VB or C++) and letting the user install
this control - then you can use client side scripting to call the control and execute
whatever code you like.
I'm not familiar with the full details though and never done that, so I can't help
further - I suspect it's not very simple to write fully working control from scratch,
and even so - few users will be willing to install fancy controls on their machine.
Posts: 668
Time spent in forums: 6 Days 7 h 4 m 19 sec
Reputation Power: 28
thx wiz,
i think i figured another way, not very good but will do the job. i figure ill leave the input form as type="file" and give the option to the user with a radion button to:uploading selected picture or entire folder that the selection is in.
do you forsee any problems with this solution
p.s. sorry for posting in code banks but i figure maybe once i get it working ill post the code here
Posts: 31,109
Time spent in forums: 3 Months 3 Weeks 2 Days 20 h 18 m 8 sec
Reputation Power: 2919
no, it's not possible. user can upload only one file at a time. you can
give directions how to zip entire folder and then upload that zip file, but not
more than that.
Posts: 31,109
Time spent in forums: 3 Months 3 Weeks 2 Days 20 h 18 m 8 sec
Reputation Power: 2919
in theory, it's possible - using command line zip utility such as pkzip. if your host allow
you to use WScript.Shell then let me know, I have something working already.
Posts: 31,109
Time spent in forums: 3 Months 3 Weeks 2 Days 20 h 18 m 8 sec
Reputation Power: 2919
yep - try this code:
Code:
<%
Dim objShell
Response.Write("testing shell...<br />")
Set objShell = Server.CreateObject("WScript.Shell")
Set objShell=Nothing
Response.Write("success!<br />")
%>
this will tell you if the component itself can be used.
Posts: 31,109
Time spent in forums: 3 Months 3 Weeks 2 Days 20 h 18 m 8 sec
Reputation Power: 2919
that's only the very first step... still far from having permissions to actually run unzip
utility. anyways, the code I have here is using licensed version of pkzip - I'm not allowed
to share this utility. in case you can get it also, here is the code needed to use this:
Code:
<% Option Explicit %>
<!-- #include file="ShadowUploader.asp" -->
<%
Const PKZIP_FILE_NAME="pkzip25.exe"
Sub ExtractZip(strFilePath)
Dim strCommand, objShell, strBatchPath
Dim objFSO, objFile
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
strBatchPath = Server.MapPath("temp_unzip.bat")
Set objFile = objFSO.CreateTextFile(strBatchPath)
objFile.WriteLine("CD "&Server.MapPath("."))
objFile.WriteLine(PKZIP_FILE_NAME & " -extract -over=all " & strFilePath & " " & ExtractDirectory(strFilePath))
objFile.Close
Set objFile=Nothing
strCommand = strBatchPath
Set objShell=Server.CreateObject("WScript.Shell")
objShell.Run strCommand, 0, True 'wait!
Set objShell=Nothing
objFSO.DeleteFile(strBatchPath)
Set objFSO=Nothing
End Sub
Function ExtractDirectory(strPath)
ExtractDirectory = Left(strPath, InStrRev(strPath, "\"))
End Function
%>
<html>
<head>
<title>Upload Test</title>
</head>
<body>
<%
Dim objUpload, x
If Request("action")="1" Then
Set objUpload=New ShadowUpload
If objUpload.GetError<>"" Then
Response.Write("sorry, could not upload: "&objUpload.GetError)
Else
Response.Write("found "&objUpload.FileCount&" files...<br />")
For x=0 To objUpload.FileCount-1
Response.Write("file name: "&objUpload.File(x).FileName&"<br />")
Response.Write("file type: "&objUpload.File(x).ContentType&"<br />")
Response.Write("file size: "&objUpload.File(x).Size&"<br />")
If Right(LCase(objUpload.File(x).FileName), Len(".zip"))=".zip" Then
Call objUpload.File(x).SaveToDisk(Server.MapPath("Uploads"), "")
Call ExtractZip( Server.MapPath("Uploads/" & objUpload.File(x).FileName) )
Response.Write("zip file saved and extracted successfully!<br />")
Else
If objUpload.File(x).ImageWidth<0 Then
Response.Write("invalid image!")
Else
Response.Write("image width: "&objUpload.File(x).ImageWidth&"<br />")
Response.Write("image height: "&objUpload.File(x).ImageHeight&"<br />")
If (objUpload.File(x).ImageWidth>200) Or (objUpload.File(x).ImageHeight>200) Then
Response.Write("image to big, not saving!")
Else
Call objUpload.File(x).SaveToDisk(Server.MapPath("Uploads"), "")
Response.Write("file saved successfully!")
End If
End If
End If
Response.Write("<hr />")
Next
Response.Write("thank you, "&objUpload("name"))
End If
End If
%>
<form action="<%=Request.ServerVariables( "Script_Name" )%>?action=1" enctype="multipart/form-data" method="POST">
File1: <input type="file" name="file1" /><br />
File2: <input type="file" name="file2" /><br />
File3: <input type="file" name="file3" /><br />
Name: <input type="text" name="name" /><br />
<button type="submit">Upload</button>
</form>
</body>
</html>
this is the same upload sample code as before, but when uploading zip file it would
unzip it into the Upload folder. the above is using PKZIP25.exe application, if you get
different zip utility let me know and I can try make the code work with that as well.