Hi chaps, I'm not terribly sure how to go about this. I've got a small site where I want to add some files for people - well me since nobody will ever use that website - to download, a sort of repository if you like a bit like github maybe, but i'm not entirely sure how. Can I use github only for a few files (in other words, is github free considering I don't have an awful lot of files) or does anybody have another suggestion? The way I picture the whole thing in my head is to have the files directly downloadable from my site rather than going somewhere else. How feasible is that? A very quick look on google brought back only github related results...
thanks

Dani AI

Generated

A practical, low-friction way to host a few code samples is to keep them on the site’s own webspace and link to them directly. Create a dedicated folder (for example /files or /downloads), upload via FTP or the host’s file manager, and maintain a simple index page. Because the host in this thread does not run .NET, .aspx pages will not execute there and will be served as static files — convenient for sharing source but a reminder to remove any secrets (connection strings, keys) from code-behind files before publishing. This follows the same basic idea and suggested about using the host or external storage.

To encourage a direct download rather than opening in the browser, the HTML5 download attribute is the easiest front-end option (works for same-origin links in modern browsers):

<a href="/web-development/files/OvertimeApp.zip" download>Download OvertimeApp.zip</a>

If older browsers or cross-origin downloads are a concern, set a server header to force attachment. On Apache hosts with mod_headers enabled, a lightweight .htaccess rule can do this:

<IfModule mod_headers.c>
  <FilesMatch "\.(zip|pdf|aspx|cs)$">
    Header set Content-Disposition "attachment"
  </FilesMatch>
</IfModule>

Not every shared host allows .htaccess changes or mod_headers—check the host settings.

For an automatically updating list, a tiny server-side lister (like the PHP example mentioned) is handy; if the host lacks server scripting, run the lister locally to generate a static index.html and upload that. Alternatives include hosting on a Git service or cloud storage for versioning/backups and linking from the site if keeping everything on the same domain isn’t required. Practical tips: use clear filenames, bundle multi-file examples as zip archives, test download behavior in several browsers, set sensible file permissions, and never publish credentials.

Recommended Answers

All 15 Replies

GitHub is free, but the free accounts do not have private repos. So anybody could access your files. If you want private, BitBucket provides that.

Uploading files to your website would be an easier solution. Do you just want it as a dropbox, or do you need file versioning?

OK cool, well I don't mind if they are public actually. If uploading to website is easier, I suppose I can go with that, and no, I don't need file versioning, so if I need to change anything on the files, I'll upload them again. So how would I go about that?
thanks

Member Avatar for Member #120589

What's wrong with Dropbox? If it's only you that uses it, then Dropbox (or similar) seems a reasonable choice. Difficult to know what to suggest as we don't know what type of filing system you have in mind. Dropbox does have limitations with regard to not syncing symlinked folders (folders that are physically outside the dropbox folder on the device but linked to the dropbox folder via symbolic link - like a glorified shortcut). I got so frustrated with this I signed up with sugarsync. It's not free, but they have very good deals at the moment.

Remember that most of these remote storage sites offer direct links to files, so you could list links on your webpage that point to files on Dropbox (or Google Drive or any other similar site).

Git is usually used for versioning or for forking your project into branches - is this what you're looking for? - but no reason why you can't use it as a general file repository? Github is free for public repos but if you want to keep your repos private, then I think its currently $7/mo. There are alternatives to github though like BitBucket - which I think has free unlimited private repos.

Well, it's not going to be a filesystem as such: basically, the files are just code samples. On my site I talk about an application I developed and then I provide the code for it (I'm specifically talking about .net application so the files will be .aspx .aspx.cs etc). As said, I don't need to keep them private, and I don't need any versioning because those files are just for me to remember what I did

Here is an example.

Ah, hang on, maybe I got things completely wrong. To store documents on an HTML site I have to use .net or any other server side language? This is the site (sorry for posting the link but I think it will help me to understand better )? The thing is the webhost doesn't support .net...

this is a php script I use for my notes, it just dumps everything in alpha order, including folders, so every application is sorted

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html;charset=utf-8'>
<title>Note Books</title>
<style>
@media print {body {font-size:10pt;}}
@media screen {body { background:url(funny_cat_pictures_76.jpg) no-repeat center right fixed;background-color:#f6f6f6;color:#000000;font-family:verdana, arial;margin:4%;}}
body {background-color:#f6f6f6;color:#000000;font-family:verdana, arial;margin:4%;}
ul.dirlist {list-style-type:none;padding-left:0.5em;margin-bottom:0.2em;text-transform:capitalize;font-weight:normal;} 
ul.dirlist li {list-style-type:none;padding-left:0.5em;margin-bottom:0.1em;text-transform:capitalize;font-weight:normal;}
ul.dirlist li:first-letter  {text-transform:capitalize;font-weight:bold;}
ul.dirlist li a {text-transform:capitalize;font-weight:normal;margin-bottom:0;}
ul.dirlist li a:first-letter {text-transform:capitalize;font-weight:bold;margin-bottom:0.1em;}
.logo {background:transparent;color:#000000;text-align:right;font-size:85%;top:auto;left:auto;bottom:1px;right:1px;position:fixed;}
.logotop {color:#000000; background:transparent;text-align:right;font-size:85%;top:10px;left:auto;bottom:auto;right:1px;position:fixed;}
.smalltext {background-color:#f6f6f6;font-size:85%;} 
.tinytext {background-color:#f6f6f6;font-size:70%;}
</style>
</head>
<body>
<h3>Note books</h3>
<ul class='dirlist'>
<?php $it=new RecursiveIteratorIterator(new RecursiveDirectoryIterator('.'));
while($it->valid()){
if(!$it->isDot()){
if(stripos('-pdf-tml-txt-asc-cob',substr($it->key(),-3))){ 
echo '<li>'.str_replace("\\","::",$it->getSubPath())." \n<a href='".$it->key()."'>\n".str_replace("_","&nbsp;",str_replace("\\","",substr(trim($it->key(),"\ ."),strlen($it->getSubPath()))))."</a><span class='tinytext'> ".number_format((filesize($it->key())/1024),0)."<span class='tinytext'>KB</span></span>\n";
echo "</li>\n";}} $it->next();} ?>
</ul>
</body>
</html>

OK I see, thanks for the code almostbob, so one way or another I will have to have a server side language script to do the job for me, sorry I didn't know, I would have thought that HTML5 had some way to host documents. I may have a look at github as well then

You can always upload files with an FTP client.

that's it, I think that's the solution. I can upload the files to my host server, but then how do I link to them from the site?

I stumbled on this today... Perhaps it's something you can use for your file repository.

Run the php on localhost with the same file structure
view page source
copy and paste the generated html as index.html
ftp to your free host
=php effecct on free host
dont need a whole wamp stack, just a mini environment like quickphp

I was hoping to try without script first, almostbob. If I create a folder in the files system on the host server, how do I link to the file so to download them? Meaning, say the files sit in a folder called files and I want to link to them from my site how do I download them rather than just view them?

depending on the browser what the exact context menu item is called
when you right click the link something like one of

save link as
save target as
save link target as

OK thanks, I saved them on the server and made sure they open on a new tab, here under the last tab "overtime application"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.