WordPress.org

Ready to get started?Download WordPress

Forums

WP Download Codes
[resolved] file link redirects to homepage instead of download file (13 posts)

  1. nubian1
    Member
    Posted 1 year ago #

    I am using the download codes plugin on http://www.djneaux.com/dev/tunes/ and I have been able to upload files to the upload folder and generate codes successfully. But, when I put in the code it takes me to the page which is supposed to have the download file. The page appears to have the file and even says what size the file is but when I click on the link it never downloads the file but takes me to http://www.djneaux.com.
    I have tried it with several files, I tried relocating the uploads folder, updating the permalink and deactivating and uninstalling the plugin then reinstalling it and starting over again but nothing has worked. Please let me know how to fix this.

    Thank you

    http://wordpress.org/extend/plugins/wp-download-codes/

  2. b0gn0z
    Member
    Posted 1 year ago #

    I've been having the same problem. At first I thought the issue was complex ID's/names for the downloads (something with spaces and symbols), and I tried changing the filename, ID name and labels to something simple - but it didn't work.
    I've tried SO MANY things to try to get this error to stop happening, and the only thing I've come up with is this:
    http://i.imgur.com/Kw4Yt.jpg
    The first download was a test I did a while ago, and it worked fine (when I changed to simple labels etc), and you can see the code ID 251.
    The other few downloads have all failed, and send me to the main URL with some generated lease ID, and they all have a code ID of -1.
    Not sure what is causing WPDC to use a download code of -1 instead of the actual code ID's but I think that's the problem.

  3. b0gn0z
    Member
    Posted 1 year ago #

    After a bit of hacking around, I've found something that's interesting, but I can't quite make sense of it yet. In dc_template.php apx line 93:

    $html .= '<p>' . dc_msg( 'code_valid' ) . '</p>';
    $html .= '<p><a>= 0 ? substr( $_SERVER['REQUEST_URI'], 0, strpos( $_SERVER['REQUEST_URI'], '?' ) ) : $_SERVER['REQUEST_URI'] ) . '?lease=' . $download_lease_id . '">' . ( $release->artist ? $release->artist . ' - ' : '' ) . $release->title . '</a> ' . format_bytes( filesize( dc_file_location() . $release->filename ) ) . '</p>';

    If you change it to something like:

    $html .= '<p>' . dc_msg( 'code_valid' ) . '</p>';
    $html .= '<p><a href="http://hard-link-to-file">' . ( $release->artist ? $release->artist . ' - ' : '' ) . $release->title . '</a> ' . format_bytes( filesize( dc_file_location() . $release->filename ) ) . '</p>';

    - It works fine. It defeats the purpose of the plugin as the link is now visible, but it indicates that the codes, number of downloads, etc are working OK.
    Now to find a solution...

  4. b0gn0z
    Member
    Posted 1 year ago #

    OK!
    After more mucking about, getting lost in a maelstrom of PHP voodoo I've managed to fix the problem. It has to do with having WordPress installed in a different directory than the root.
    SO, all I did was change dc_template.php line 95:

    $html .= '<p><a>= 0 ? substr( $_SERVER['REQUEST_URI'], 0, strpos( $_SERVER['REQUEST_URI'], '?' ) ) : $_SERVER['REQUEST_URI'] )."/home/index.php" . '?lease=' . $download_lease_id . '">' . ( $release->artist ? $release->artist . ' - ' : '' ) . $release->title . '</a> ' . format_bytes( filesize( dc_file_location() . $release->filename ) ) . '</p>';

    The change being the addition of "/home/index.php" before the lease id.
    So if you update /home/ to wherever your wordpress is installed hopefully it will fix your problem too.

  5. nubian1
    Member
    Posted 1 year ago #

    Thanks so much! Moving my WP files to the top level directory worked.

  6. mliotta
    Member
    Posted 1 year ago #

    WOW!! Thank you sooooo much! My DL code has been doing this for about a year, and I have a record out that nobody could download my codes for.. It used to work and then something happened, anyway with the advise above it now works!!! You are totally awesome!! Thank you!!

    http://www.mliotta.com

  7. StevieD009
    Member
    Posted 1 year ago #

    I'm having this same issue, and can't seem to get it to work. I have my wordpress installed in a directory called "wordpress". I've tried to use your code here every which way I can and the best result I get is that it simply sits on the download page like it's trying to do something but nothing happenS, just keeps sitting there in a busy state.

    Using the entire code you posted for line 95 gives me errors, looks a bit different than what I have, but I've arrived at this for line 95:

    $html .= '<p><a href="http://' . $_SERVER['HTTP_HOST'] . ( strpos( $_SERVER['REQUEST_URI'], '?' ) >= 0 ? substr( $_SERVER['REQUEST_URI'], 0, strpos( $_SERVER['REQUEST_URI'], '?' ) ) : $_SERVER['REQUEST_URI'] ) . "/wordpress/index.php" . '?lease=' . $download_lease_id . '">' . ( $release->artist ? $release->artist . ' - ' : '' ) . $release->title . '</a> ' . format_bytes( filesize( dc_file_location() . $release->filename ) ) . '</p>';

    Notice that I've indicated where my wordpress is located, but can't seem to get it to work. BTW, I had the codes working fine when I initially installed this, so I'm not sure why they aren't working now?

    Any and all suggestions would be greatly appreciated!

    url: http://www.patchworxmusic.com/wordpress/downloads/

    code for testing: BIGERYZ1S59

    THANKS!

  8. StevieD009
    Member
    Posted 1 year ago #

    UPDATE: I've noticed that if I refresh the page (as it is just sitting thinking) that the download will start? I think I'm on the right track, and now I can tell it's looking in the right direction, but not sure why it gets stuck? THANKS AGAIN SO MUCH!

  9. hollyrock
    Member
    Posted 1 year ago #

    I'm having this problem too of my downloads redirecting to my home page, but I don't understand b0gn0z's fix. I don't know what "dc_template.php line 9"5 means and where I would find it to change "/home/index.php". Can someone please explain?

  10. hollyrock
    Member
    Posted 1 year ago #

    I previously had my folder containing the zip file in /public_html/blog/wp-content/uploads/

    I moved it up to /public_html/blog/wp-content/ and they're still redirecting to the homepage.

    Is that what nubian1 meant by moving the WP files to the top level directory?

  11. hollyrock
    Member
    Posted 1 year ago #

    So I moved my file to /public_html/blog/wp-content/ which is where I think it should be (but who knows since there's apparently no developers to help out here?) and now under Manage My Releases it says "No files have been uploaded to the releases folder: /public_html/blog/wp-content/ You must do this first before adding a release!"

    But I did upload my release to the correct folder, so what can I do to make it recognize the files?

  12. StevieD009
    Member
    Posted 1 year ago #

    Hi hollyrock,
    I think the moderator has all but given up here, so we're on our own. I was able to resolve the issue I was having by adding an "external" class to the code, it's a bit over my head, but something in the theme I'm using was interfering with the download. Here's a communique from my web guy explaining how we resolved it on our end.

    Since the downloads links are also using short code, I was able to put a line of javascript on the downloads page that will add the "external" class to the download links. It worked great for the promo code download.

    Note that we added class="external" to the download links, and it solved the issue.

    I hope that helps, let me know how it comes out.

    - s

  13. hansvandamme
    Member
    Posted 1 year ago #

    I had the same problem, since my wp install is not in the root of the webserver. Instead of hard-coding the install path in the script, I just made a call to site_url(). This should make the script work in all cases. At least it does for me.

    I changed line 95 into: $html .= '<p><a href="'.site_url() . '/index.php?lease=' . $download_lease_id . '">' . ( $release->artist ? $release->artist . ' - ' : '' ) . $release->title . '</a> ' . format_bytes( filesize( dc_file_location() . $release->filename ) ) . '</p>';

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic