file download

Posts: 68
Joined: 01/22/2008

I'm having a lot of trouble getting the file download to work. I get to the area where you set features and need to enter the pathname.

This is the text just below that slot where you enter the path.

The file that can be downloaded when product is purchased. Entering a directory will allow all files in that directory to be downloadable.

I have a folder called "files" and I can't get it to take. It continues to return the error:

files is not a valid file or directory inside file download directory.

I've tried different names; I've tried slashes and no slashes. I've changed permissions on the folder. I can upload to this folder using Ubercart, but I can't get it to take the name of the folder.

The other feature "add role" works fine. Everything else on my site so far seems to work fine.

Can anyone help me with this?

Dan

Posts: 1293
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

Yes. You are better off using a local (full) path to your folder, for instance:

/var/www/vhosts/example.com/httpdocs/files

If your files folder is outside/ above your webroot (which is recommended), like this:

/var/www/vhosts/example.com/files

Then you'll need to make sure you have access to those files. In normal PHP / Apache setups, there is a directive called open_basedir. What that means is that scripts cannot go outside the directory specified in this directive.

If you have full access to the server, you'll need to change it (either in php.ini, or vhosts.conf).. or you can ask your server admin to take care of it.

Hope this helps.

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 68
Joined: 01/22/2008

There must be something more fundamentally wrong than the pathname. I can't get ANY path name to work here. My root folder is plan2. So the path I'm using is plan2/files/private. Of course I've also tried: /files/private plan2/files/private /plan2/files/private files/ etc. All return the same error. When I "view File Downloads" I see two files, and I can also upload a file and it puts it into /files/private But if I assign the path files/private to the product, the path name is set to be invalid.

Is this a database problem? Although I did a clean install today with a brand new database. So I doubt that's it.

Dan

Posts: 1293
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

Have you set permissions on the folder? I believe they'll need to be 0755 or 0766, Global Read/Write, in order for your directory to be accessible. If the folder is below the webroot, as you've described - so that it's available to the public (and you can get a file by going to http://example.com/files/private/foo.bar) then your method is correct.

Remember the web root is different from the server root, and I'm not 100% sure that the File Downloads module can accept a relative path. You may need to use a full path. (Shawn please, correct me if I'm wrong here..)

It's not a database problem, though. It is most likely a permissions problem, or a PHP/Apache issue (the open_basedir problem I mentioned before).

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 68
Joined: 01/22/2008

Yes, thanks again. I have tried different permissions--including the 755 and 756 on that folder.

I'm not sure I know where the php.ini file is. I can get into the MySQL database but I'm not sure i have full access to the server.

But it seems if I use a folder within the root, then that's not an issue.

It doesn't seem that I can get direct web access to files within my drupal root folder.

Gosh, just not sure what to try next. Can I give you admin access to the site to take a look?

I note too that the file is here http://www.writingdepartment.org/plan2/files/private/esplanner_basic.txt But that doesn't open that file, so as you say, there must be some permissions problem.

Dan

Posts: 332
Joined: 08/07/2007
Administrator

Relative paths might work, I can't say for sure since I hadn't tested it out. I only supported an absolute path so there's no ambiguity of where the file download directory exists. If it does work it would probably work with a path relative to the drupal root folder since that would be the directory Drupal's PHP runs from (and thus attempts to open files from). By the way, if anyone needs to get the absolute path of their virtual server directory they can do so with the following PHP code.

<?php
 
echo $_SERVER['SCRIPT_FILENAME'];
?>

This should spit out the absolute path of the PHP script running the code.

Edit: Ryan has confirmed that placing a path relative to the Drupal root works as well.

--

-Shawn Conn: If the Name Don't Rhyme It Ain't Mine

Posts: 19
Joined: 01/13/2008

I hope someone is still monitoring this thread, because I too keep getting the error: "C:\whatever\file i'm trying to get.doc is not a valid file or directory inside file download directory." I originally placed it in c:\my downloads because I thought I was following the instruction to keep it outside the webroot. After reading this thread I tried moving it up and up and up one level at a time until it was in the files folder inside drupal, but it never made any difference, I always got this error. Where, or what, is the 'file downloads directory' anyway? I do have server access. I am on Windows. All help appreciated. Thx.

Posts: 1293
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

The error you're getting shouldn't be for a file, this is is about the file downloads directory being setup here: /admin/store/settings/products/edit/features

The field is called "Files path" - this should be different from the files/ directory used by Drupal (for uploads, comment attachments, etc.) - these are the files that will be attached to your product feature (File Downloads).

So the folder you put here should be the path, relative OR absolute, where you'll be uploading your files that are available for purchase. Then when the links are generated, at checkout / successful order completion, the downloads will come from there. You can verify this by viewing your list of files available to Ubercart at /admin/store/products/files

If this is all setup correctly then you shouldn't be getting the error. Make sure that the files folder has permissions setup. You may need to play with it, since you're using Windows / IIS you'll need to right-click the folder in your Files view and give it Read/Write properties.

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 19
Joined: 01/13/2008

ok, maybe i'm being dense, but this isn't working for me. I had c:\my downloads set here in the file path when I started getting this error in the first place. I did that because the instructions plainly say it should be outside the web root. But if I am understanding your earlier post in this thread, 'outside' does not mean 'too far outside'. So does that mean inside the server root but not inside the webroot?

I'm no coder but I would like to understand what i am doing and how this all works.

I have created a folder called 'downloadable' and put my file to be downloaded in it. I have put this folder on the same directory as the drupal folder. I set it as a sharing folder in windows. I set it with an absolute path in the file path. I still get the same error. Does the file download only recognize certain file types? This is a .doc file I was testing with.

p.s. - in home > administer > Store administration » Products > view file downloads, the file in question is listed. It does not have an sku or a product, presumably because I can't edit the features tab, but it does show up here so isn't that telling me ubercart knows where it is at the same time it is telling me it isn't in a valid directory? If so, where is the valid directory? thx.

Posts: 1293
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

Just to make sure - are you setting this up on a Windows server, or on your local machine running Apache in windows?

Secondly, you don't need the "C:\" in your file path. You just need the folder name. And chances are, if you are using a Windows server, it's probably not from the root of your drive, but probably a web folder or something similar. (I haven't used Windows Server for deploying websites in a long time..).

However if you're saying that the file is showing up under Products > View File Downloads, then I'm not sure what else could be going on. When I said that the path should be "outside" I didn't mean "not to ofar" or anything. You can really put the downloads wherever you want, but to be on the safe side, I'd keep them above your web root, which is usually something along the lines of "htdocs," "httpdocs" or "www" .. sometimes even "web_root". It varies setup-to-setup, really.

You said that you set the downloads folder as a sharing folder in Windows, but that's not quite what I meant. In IIS you can tell the server whether or not to allow Public Read, Write or Execute permissions on a file, or on a folder. Sharing in Windows usually means other users on the LAN can access a particular folder.

If you can explain your setup a little further, maybe Shawn or someone else can help who has better knowledge of IIS (if that is in fact what you're using). I'm a lot better with Linux web servers. I highly recommend them Smiling

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 19
Joined: 01/13/2008

I stopped the file from being shared. It already has read and execute permissions on it. I added 'write'. But I still get the exact same error.
This is a WAMP setup. I tried changing the file name to take out spaces, which windows allows. I still get the same error.

In store administration status messages, it says file downloads diretory has been set up and is working. Where is this directory?, Is this where drupal/ubercart is looking for my download files? I would think not, since it is supposed to be outside the webroot.

Why does the test file show up under 'view file downloads' - even now under the new name I gave it - if it isn't in a valid directory?

Quote:
Secondly, you don't need the "C:\" in your file path. You just need the folder name.
Under product settings > file path it says "the absolute path...." Isn't the root drive part of the absolute path?

I don't understand this at all. Sad Up to now everything has worked just by me reading the threads and playing around with it. I would appreciate any insight from any one. Thx.

Posts: 332
Joined: 08/07/2007
Administrator

Ok, there's a lot questions I've seen pop up in this thread that I'll try to address all at once.

For the file downloads dir in /admin/store/settings/products/edit/features, if you're using absolute paths in Windows you need to use "<DRIVE LETTER>:/..." just as you would use "/..." in Linux. As mentioned previously, paths relative to your Drupal root also work (I've committed to bazaar a change in the description to reflect this).

The file path can be any file system path on your machine that PHP has read/write access. Having read access only will work, but you won't be able to remove or upload files through the file manager (admin/store/products/files).

Any file will work with the module, with the exception of some system files that start with "." like .htaccess because the way drupal's file_scan_directory scans for files within a directory.

To address your specific problem, natcolley, where exactly are you receiving the error and what is the error message? If that .doc file is showing up in the file manager (admin/store/products/files) then the module shouldn't be complaining about an invalid directory. The reason you see no SKU or product in the file table is that you must first add a product feature (by using node/*/edit/features) to a product before the file is associated with a product & SKU.

--

-Shawn Conn: If the Name Don't Rhyme It Ain't Mine

Posts: 19
Joined: 01/13/2008

Shawn Conn wrote:
To address your specific problem, natcolley, where exactly are you receiving the error and what is the error message? If that .doc file is showing up in the file manager (admin/store/products/files) then the module shouldn't be complaining about an invalid directory. The reason you see no SKU or product in the file table is that you must first add a product feature (by using node/*/edit/features) to a product before the file is associated with a product & SKU.

And it is at the product feature tab that I get this error. Now what?

Posts: 332
Joined: 08/07/2007
Administrator

Does this occur when you submit a new file download feature or just when when you browse to the product features tab?

--

-Shawn Conn: If the Name Don't Rhyme It Ain't Mine

Posts: 19
Joined: 01/13/2008

I am new to drupal/ubercart and I am just trying to set up my store. This is the first and only time this has happened.

Please see attached if that helps you help me any.

Posts: 332
Joined: 08/07/2007
Administrator

Ok, the first image was all I need to see what's going on. You're adding the absolute path to the file, the form field only needs a relative path to the downloads directory. I should have specified that in the description text (a better description has now be committed to bazaar). Just type in the file name (sans directory path) and you should see the autocomplete field display files it has found in the directory.

--

-Shawn Conn: If the Name Don't Rhyme It Ain't Mine

Posts: 2
Joined: 01/28/2008

The way I did this was to create a file in the directory above my public_html (www) folder called 'dfiles' (for download files) then went back to the file settings and started to add '../dfiles' (without quotemarks) and submitted, if it didnt work I changed it to '../../dfiles' and so on until it found the file by itself, if you keep changing the place where you think it is supposed to be, as well as changing the location of where you want drupal to look it will be very difficult to find, if you keep the 'dfiles' folder in the same directory tree (usr/dfiles/public_html(www)/store/admin/files' then it will find it eventually, all you really have to do is keep adding '../' until it finds it, if it goes out side the straight line directory then it will be more difficult to find it.

Hope this helps.

Jimmy (also a noob!)

Posts: 22
Joined: 02/13/2008

I share in the massive confusion regarding this path; beneath the space to enter the name of the file to be downloaded, it says "The file that can be downloaded when product is purchased (enter a path relative to the directory)"

Relative to WHAT directory? Drupal itself? The dir inside Drupal called 'files' ? This is not clear AT ALL!

I'm not at all sure how to "back up" in the path, in web pathnames; I know the DOS/Windows convention is to use dot-dot-some-kind-of-slash (..\ or ../) but I don't know if that works on the web; my host uses Redhat Linux server. (Servage is the host).

I have Drupal installed in the root of the domain, www.crypticsites.biz. I have a dir inside it called 'files' which is where the files went when I uploaded logo and favicon files thru Drupal, and where, I presume, free download files will go. Do I need to put the purchasable files in that dir, or in some other dir, and if so, how do I go about specifying that dir? I know the server path, so I can specify that if that's what's needed, but this desperately needs clarification!

Thx
Andria

Posts: 924
Joined: 11/05/2007
Bug FinderFAQ ModeratorGetting busy with the Ubercode.

First, configure file downloads at admin/store/settings/products/edit/features. There, you specify the base directory for the files using the text field "Files path:". After you do this, the message "The file that can be downloaded when product is purchased (enter a path relative to the directory)" will include the name of the directory. It is not descriptive for you right now because you haven't configured file downloads. The directory you set should not be located under ~/www or ~/public_html or wherever your web server stores pages.

You will probably want to put all your file downloads in the directory you enter on the configuration page. But if you want to put some in a subdirectory, then you can enter a relative path on the product feature edit page, like node/#/edit/features. If you do things this way, you should not have to use ../ because everything will be in a subdirectory.

--

<tr>.

Posts: 22
Joined: 02/13/2008

I got this setting working fine -- and now I've moved my Drupal site to a new host, because my old host had such crappy mysql servers -- and now I can't get it to work.

The path I'm told that is the path to my root is /home2/literate

So I tried to put my dir pvtdls into that dir, giving me /home2/literate/pvtdls, and set the perms to 777. I got the error
/home2/literate/pvtdls is not a valid file or directory

So I asked my new host's admin about the path; he suggested that I put pvtdls into public_html, which is ok because it's still below the root of my drupal site; so I tried that, giving me /home2/literate/public_html/pvtdls, and made sure it was set to 777. And I STILL get
/home2/literate/public_html/pvtdls is not a valid file or directory

I ran the php snippet given above, to get it to spit out my actual path, and sure enough, it told me my path was /home2/literate/public_html.

So, now what?

(pulling out hair)

Andria

Posts: 332
Joined: 08/07/2007
Administrator

The location, outside or inside, your web directory shouldn't matter as long as PHP has access to the directory. Before saving the location, uc_file uses is_dir to see whether the entered value is a directory that PHP can view. For some reason, that check is failing. Is this a Windows or Linux host?

--

-Shawn Conn: If the Name Don't Rhyme It Ain't Mine

Posts: 22
Joined: 02/13/2008

It's Linux. Here's all the version info:

Apache version 1.3.41 (Unix)
PHP version 5.2.5
MySQL version 5.0.45-community-log
Architecture i686
OS Linux
Kernel version 2.6.9-67.ELsmp

I worked on this problem for about 3 hrs with my host's admin Thursday night and never could make it work. Then it occurred to me that I had just picked up and moved the entire dir structure of Drupal/Ubercart, and that there are numerous .htaccess files therein, and that those might not have xferred properly, and/or dir permissions might not *all* be set correctly. So I'm going to try a new install of everything and see if it helps. It's worth it for 1) a host this fast, and 2) a host with admin that care that much! Laughing out loud

Thx much!
Andria

Posts: 2
Joined: 06/03/2008

please send Ubercart coding script

Posts: 2
Joined: 06/03/2008

hi,
i have travel with Ubercart not define where set payment option please give complete solution how to used os commerce with druple Ubercart

Posts: 2244
Joined: 08/07/2007
AdministratoreLiTe!

osCommerce plus Drupal would probably be even worse than just osCommerce by itself.

Posts: 2
Joined: 06/02/2008

hi aloksoft2004

u got a simple problem,payment options are in administrator->Store

administration->configuration->payment settings.And set the payment options like

1.payment settings

2.payment methods

3.payment gateway

u can set the permissions(enable the check box) based on u r requirement,

and set the desired payment methods u want to access.