tycoonbob Posted January 13, 2011 Share Posted January 13, 2011 Hello all. In lack of better terms, I am a programming noobie when it comes to designing code. I can look at a code and figure it out, but basically I am trying to figure this out. I host a website from home, running on a server 2008 machine, with apache/php, basically to share files from home, work, friends house, wherever I need. I do have a FTP for this, but I also want to be able to upload files via http. I actually want to be able to set a time or date that the file will auto-delete. Such as, I select a file from my local machine, set the deletion time to 1 hour/60 minutes/3600 seconds, whatever, upload it to the site, and it spit back a url that I can access that file for that set amount of time. It would be great to implement something like bit.ly to shorten the link, or even something to randomize the link. Any ideas on that from anyone? Willing to donate (paypal) a little bit if someone can actually help me out, or point me in the right direction. A week on google has proved useless. Thanks so much. Quote Link to comment Share on other sites More sharing options...
snowman15 Posted January 13, 2011 Share Posted January 13, 2011 If I were you, I would create a database with an id,filename,endtime From there you could have a page that takes in a get variable such as mysite.com/getfile.php?id=4 This page would then check the database endtime for that id against the current date, delete the file if necessary and spit back an error, or show the file because it is still in the timeframe. Basically nothing would be done automatically, but everytime someone tries to access the page, it does the check so it appears as though it was deleted at its expiration time. another option would be to check every single file/delete them in the entire database per every page request, so it would most likely be a little more up to date. Hope this plants an idea, let me know what you think. Quote Link to comment Share on other sites More sharing options...
MatthewJ Posted January 13, 2011 Share Posted January 13, 2011 Like snowman said... I would do something like that, but then use a scheduled task to run the script on an interval to check for and delete expired files. Quote Link to comment Share on other sites More sharing options...
snowman15 Posted January 13, 2011 Share Posted January 13, 2011 The process would look something like this in chronological order: go to upload site upload file store id,filename,expiredate in database spit back download page with ?id=# from the file just uploaded go to download.php?id=# page performs check for expiration, deletes if necessary, or spits out the file optional: delete database record AND file on expiration optional: check/delete all files regardless of incoming ID every page load, slower, but files stay more up to date ^^this is a more simple option And like matthew said, you could use something like 'cron' to automatically do it reguardless of people visiting your page. But thats up to you. Quote Link to comment Share on other sites More sharing options...
tycoonbob Posted January 13, 2011 Author Share Posted January 13, 2011 Yes, that idea sounds great. I figured some kind of db could be used. My experience in SQL is as much as in php/xml. I can create users/databases, and set permissions from the CLI. Would it be possible to find a guide to doing something like this, or have a nice little write up? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.