Hey everyone, I'm wondering how I would create a download script where all I have to do is upload a file to a folder, and it automatically shows up for download on the download page. This is what www.dohgames.com has, and it would really be handy for the website I am developing which will have tons of files for download that I don't want to enter in manually for it to be downloadable. If anyone could explain or direct me to a tutorial, that would be great. Thanks
While uploading put something(filename,patch, etc.) to database. And for download page just extract that data from database.
Ok, can you explain how to set it up so when I upload a file, it automatically adds that info to the database?
Okay, I did a bit of reading there, and I'm lost. Would I do that, and if it returns true, then I would have it insert ['userfile'] or ['name'] into the database? But isn't that only for if you upload from a page I set up on the site? I'm wanting to simply upload the files via an FTP client like FlashFXP and have the files show up for download on a page. Is that possible?
Oh, I thought that you want to upload files via form on webpage. About uploading through FTP. Put the files in a seperate directory and check all the files in directory. Then just make links to them... http://php.net/manual/en/function.readdir.php
Hey I've got it working, but now I have another question. I have my files for download in a directory above /public_html/. How do I link to the files so they can be downloaded?
you have to make PHP put the file name and the file size in the headers then print the file. I will give you the code when i get home if no one else has posted it
Here's the code I'm using: <?php $count = 0; if ($handle = opendir('./../downloads/nes')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") {$count++; print("<a href=\"".$file."\">".$file."</a><br />\n"); } } echo '<br /><br /><a href="..">Return</a>'; closedir($handle); } ?> Code (markup):
So what I'm wondering is, what do I change print("<a href=\"".$file."\">".$file."</a><br />\n"); Code (markup): to so that the link can be to a file in a directory above /public_html/ ?
you cant the way webservers work it you can only access the web directory alltho you could use PHP and .htaccess to do it
Nevermind that. Using the code I posted above, how would I make it show the links in alphabetical order?