Solved

Using SaveVirtual and SaveAsVirtual to differnet directories

Posted on 2006-07-12
8
423 Views
Last Modified: 2012-06-21

I am trying to upload two images from the same form to two different directories.  My host requires that I use SaveVirtual and SaveAsVirtual.

I want the name of the file to be changes to the serial ID of the item that is being uploaded to the database (hence 'Name = "/"&pro_id&".jpg"')

It does work and upload the files to the correct directories with the correct filenames.

The problem:  It also uploads the origional image files in the /images/ folder.

How can I produce the same result without uploading the origional images?

Thanks

Here is the code I have:

<%      
      Set Upload = Server.CreateObject("Persits.Upload.1")
      Count = Upload.SaveVirtual("/images/")
      %>
<% = Count %> files uploaded.


      Set File1 = Upload.Files("filesmall")
      Set File2 = Upload.Files("filebig")
       Name = "/"&pro_id&".jpg"
      ' Save
            If Not File1 Is Nothing Then       File1.SaveAsVirtual "/images/products_small" & Name
            If Not File2 Is Nothing Then       File2.SaveAsVirtual "/images/products_big" & Name
      
0
Comment
Question by:dougbrill
  • 5
  • 3
8 Comments
 
LVL 25

Expert Comment

by:kevp75
ID: 17094269
please post the entire code, not just a snippet of it.  your issue lies elsewhere
0
 

Author Comment

by:dougbrill
ID: 17094354
Here is the entire code

Thanks

<%      
      
      Set Upload = Server.CreateObject("Persits.Upload.1")
      Count = Upload.SaveVirtual("/images/")
      %>
<% = Count %> files uploaded.

<!-- #include file="connectdb.asp"-->
<%
set rs=server.createobject("adodb.recordset")
rs.open "products" , conn,1,3
rs.addnew
      rs("pro_name")            = upload.form("txtName")
      rs("pro_detail")      = upload.form("txtDetail")
      rs("pro_color")            = upload.form("txtColor")
      rs("pro_item_no")      = upload.form("txtCode")
      rs("cat_id")                  = upload.form("category")
      if  upload.form("wholesale") = "Yes" then rs("wholesale") = true else rs("wholesale") = false      
      if  upload.form("normal") = "Yes" then rs("normal") = true else rs("normal") = false      
rs.update
pro_id = rs("pro_id")
set rs = server.CreateObject("adodb.recordset")
rs.open "product_size_price" , conn, 1,3
if  instr(upload.Form("txtSizePrice"),vbCrlf)  then arrLine = Split(trim(upload.Form("txtSizePrice")),vbCrlf) else arrLine  = array(trim(upload.Form("txtSizePrice")))
for each i in arrLine
      if i <> "" then
            arrSizePrice = Split(i,",")
            rs.addnew
            rs("pro_id")       = pro_id
            rs("pro_size")       = arrSizePrice(0)
            rs("pro_price") = arrSizePrice(1)
            rs("pro_weight") = arrSizePrice(2)
            rs.update
      end if
next
'#############################
set rs2 = server.CreateObject("adodb.recordset")
rs2.open "product_size_price_wholesale" , conn, 1,3
if  instr(upload.Form("txtSizePrice2"),vbCrlf)  then arrLine2 = Split(trim(upload.Form("txtSizePrice2")),vbCrlf) else arrLine2  = array(trim(upload.Form("txtSizePrice2")))
for each i2 in arrLine2
      if i2 <> "" then
            arrSizePrice2 = Split(i2,",")
            rs2.addnew
            rs2("pro_id")       = pro_id
            rs2("pro_size")       = arrSizePrice2(0)
            rs2("pro_price") = arrSizePrice2(1)
            rs2("pro_weight") = arrSizePrice2(2)
            rs2.update
      end if
next
'##################################
       Set File1 = Upload.Files("filesmall")
      Set File2 = Upload.Files("filebig")
       Name = "/"&pro_id&".jpg"
      ' Save
            If Not File1 Is Nothing Then       File1.SaveAsVirtual "/images/products_small" & Name
            If Not File2 Is Nothing Then       File2.SaveAsVirtual "/images/products_big" & Name
      


      
rs.close : conn.close : set rs=Nothing : set rs2=Nothing  : set conn=Nothing
%>
<script language="javascript">
            alert('saving data have done.');
            window.location='addproduct.asp';
</script>
0
 
LVL 25

Expert Comment

by:kevp75
ID: 17094483
i'm curious.  You say it uploads the files to the correct directory, but also uploads them to the /images/ folder?

according to the code you posted they should only be getting uploaded to the /images/ folder, and nowhere else?

or is each product getting it's own folder?
my initial guess would be that the files are getting saved as /images/products_smalltheID.jpg and /images/products_bigtheID.jpg respectively.

try removing the / in:

Name = "/"&pro_id&".jpg"

and change:
If Not File1 Is Nothing Then      File1.SaveAsVirtual "/images/products_small" & Name
          If Not File2 Is Nothing Then      File2.SaveAsVirtual "/images/products_big" & Name


to:
If Not File1 Is Nothing Then      File1.SaveAsVirtual "/images/products_small/" & Name
          If Not File2 Is Nothing Then      File2.SaveAsVirtual "/images/products_big/" & Name
0
 

Author Comment

by:dougbrill
ID: 17094590
The objective is to upload two images for each product.  1 is a thumbnail and the second is the large image.

The thumbnails should be going in the the "/images/products_small/" directory and the large image should be going into the "/images/products_big/" directory.
As I mentioned this is actually working.

In addition, it is uploading both images to the "/images/" folder with the files origional name.  That is what I do not want.

I tried what you suggested:

Set File1 = Upload.Files("filesmall")
      Set File2 = Upload.Files("filebig")
       Name = &pro_id&".jpg"
      ' Save
            If Not File1 Is Nothing Then       File1.SaveAsVirtual "/images/products_small/" & Name
            If Not File2 Is Nothing Then       File2.SaveAsVirtual "/images/products_big/" & Name


This is the result:

Microsoft VBScript compilation error '800a03ea'

Syntax error

/backend/insertproduct.asp, line 61

Name = &pro_id&".jpg"
-------^

Is it possible to upload to two differnet directories using SaveViirtual?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 25

Expert Comment

by:kevp75
ID: 17095312
sorry...little typo on our part.....
change:
Name = &pro_id&".jpg"

to:
Name = pro_id&".jpg"
0
 
LVL 25

Expert Comment

by:kevp75
ID: 17095318
as far as I know it is.  (well....at least according to Persits manual)
0
 

Author Comment

by:dougbrill
ID: 17095557
That again worked and saved the files with thier new name to the correct folders but it still saves the origional files to the /images/ folder.

Any other ideas?

Thanks
0
 
LVL 25

Accepted Solution

by:
kevp75 earned 250 total points
ID: 17095811
can't believe I didn't see it before.

with these lines here:
Count = Upload.SaveVirtual("/images/")
<% = Count %>

you are saving the files to the /images/ directory

comment them out, and you will lose your file count, however the files will not get saved to the /images/ directory

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Grab data from remote page 10 61
Classic ASP - cannot find folder on the server 5 31
How to solve this equation 3 52
Dreamweaver server behavior gone 6 112
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now