Search found 26 matches

by Ehrmantraut
Mon May 30, 2016 2:16 am
Forum: PHP
Topic: Temporary Download Script - Unlink file after download
Replies: 3
Views: 17228

Re: Temporary Download Script - Unlink file after download

Hi Jacek,

Yes, I would prefer if the file was deleted after it had expired.
by Ehrmantraut
Thu May 05, 2016 3:34 pm
Forum: PHP
Topic: Temporary Download Script - Unlink file after download
Replies: 3
Views: 17228

Temporary Download Script - Unlink file after download

Hi Folks, Quick question: How would I go about using the unlink(); function to delete files from the 'files' folder after a user has downloaded the file? Download.php File <?php include('core/inc/init.inc.php'); if (isset($_GET['file_id'])) { $file_id = (int) $_GET['file_id']; $file = mysql_query(&q...
by Ehrmantraut
Mon Feb 03, 2014 8:25 pm
Forum: Tutorials
Topic: Problems with the Unique download link tutorial
Replies: 3
Views: 3069

Re: Problems with the Unique download link tutorial

Hi, I thought I had the script working correctly. However I've come across a problem, If I don't browse for a file too upload and hit upload twice the "Download file" hyperlink appears and allows me to download "download.php". Original Tutorial Link --> http://betterphp.co.uk/boa...
by Ehrmantraut
Thu Jan 30, 2014 2:26 pm
Forum: Tutorials
Topic: Problems with the Unique download link tutorial
Replies: 3
Views: 3069

Problems with the Unique download link tutorial

Hi,

After taking a break for 5 minutes I came back and realized where I went wrong. Correct code below;
echo'<a href="download.php?code='.$unique_code.'">Click</a>';
Thanks anyway for your help, ScTech
by Ehrmantraut
Sun Jan 19, 2014 11:57 pm
Forum: General Chat
Topic: Tutorials?
Replies: 15
Views: 13189

Re: Tutorials?

Sounds like a great idea folks. Sorry I haven't been around much had a few family issues I had to sort out.
by Ehrmantraut
Thu Aug 29, 2013 11:30 pm
Forum: PHP
Topic: Temporary link Download
Replies: 30
Views: 16950

Re: Temporary link Download

Temor wrote:
davestechuk wrote:
Temor wrote:Hooray!
lol, Temor I'm glad its finally working as well. Thanks again guys for your help it really is appreciated shame there isn't more folks like yourselves on the internet willing to help with coding issues. :)
We're a rare breed ;)

lol, Thanks again I appreciate it.
by Ehrmantraut
Thu Aug 29, 2013 2:49 pm
Forum: PHP
Topic: Temporary link Download
Replies: 30
Views: 16950

Re: Temporary link Download

Temor wrote:Hooray!
lol, Temor I'm glad its finally working as well. Thanks again guys for your help it really is appreciated shame there isn't more folks like yourselves on the internet willing to help with coding issues. :)
by Ehrmantraut
Thu Aug 29, 2013 2:40 am
Forum: PHP
Topic: Temporary link Download
Replies: 30
Views: 16950

Re: Temporary link Download

Found the issue in upload.php :) You can go ahead and remove those lines I told you to put in if it works. if (in_array($file_ext, $allowed_ext) ===false){ $errors[] = 'File extension not allowed'; Right here you are not ending the bracket until later on so you are only defining $expiry if they upl...
by Ehrmantraut
Thu Aug 29, 2013 2:13 am
Forum: PHP
Topic: Temporary link Download
Replies: 30
Views: 16950

Re: Temporary link Download

We are here to help :) Try putting this under your opening PHP tag at the top of upload.php error_reporting(E_ALL); ini_set('display_errors', 1); The only error I'm getting with error reporting turned on is Notice: Undefined variable: expiry in /home/davestec/public_html/tutorial/upload.php on line...
by Ehrmantraut
Wed Aug 28, 2013 11:43 pm
Forum: PHP
Topic: Temporary link Download
Replies: 30
Views: 16950

Re: Temporary link Download

What happens if you remove the quotes around $expiry in your upload query? mysql_query("INSERT INTO files (file_name, file_expiry) VALUES ('{$file_name}','{$expiry}')"); mysql_query("INSERT INTO files (file_name, file_expiry) VALUES ('{$file_name}',{$expiry})"); It is, after all...
by Ehrmantraut
Wed Aug 28, 2013 8:59 pm
Forum: PHP
Topic: Temporary link Download
Replies: 30
Views: 16950

Re: Temporary link Download

Could you post all the code you have now, so I can get an overview? File Name: init.inc.php <?php mysql_connect('localhost','username','password'); mysql_select_db('database'); ?> File Name: upload.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/...
by Ehrmantraut
Wed Aug 28, 2013 7:42 pm
Forum: PHP
Topic: Temporary link Download
Replies: 30
Views: 16950

Re: Temporary link Download

Please post file_list.php in case there's a difference. Also, what are the expiry values in the database both when you don't insert a number, and when you do. <?php include('assets/inc/init.inc.php'); $files = mysql_query("SELECT file_id, file_name, file_expiry FROM files"); ?> <html> <he...
by Ehrmantraut
Wed Aug 28, 2013 2:58 pm
Forum: PHP
Topic: Temporary link Download
Replies: 30
Views: 16950

Re: Temporary link Download

ScTech wrote:You're missing apostrophes around $expiry in your query on upload.php
Files is now showing in the file_list.php. but, I can't download the file as its set the date and time to the following 01/01/1970 00:00:00
by Ehrmantraut
Tue Aug 27, 2013 11:52 pm
Forum: PHP
Topic: Temporary link Download
Replies: 30
Views: 16950

Re: Temporary link Download

One small problem. Where it is validating with ctype_digit, you are using echo which won't stop it from continuing. You should set that as $errors instead of echoing it. Have you edited file_list.php since? What does the database show when you leave it blank and when you insert a number? No, I have...
by Ehrmantraut
Tue Aug 27, 2013 2:50 pm
Forum: PHP
Topic: Temporary link Download
Replies: 30
Views: 16950

Re: Temporary link Download

You shouldn't just paste the code in there. You have doubles now! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Upload a File</title> <style type="text/css"> table { border...
by Ehrmantraut
Tue Aug 27, 2013 3:14 am
Forum: PHP
Topic: Temporary link Download
Replies: 30
Views: 16950

Re: Temporary link Download

Don't take me the wrong way here. All you have to do is just follow the steps of the code and find the one where your modification fits. It's like a puzzle. You have to look at the part you're gonna put in and take note that it is giving $expiry a value, and then match it to where you do that in yo...
by Ehrmantraut
Mon Aug 26, 2013 10:31 pm
Forum: PHP
Topic: Temporary link Download
Replies: 30
Views: 16950

Re: Temporary link Download

Beat me to it Temor :) I should also mention that you should look into checking file extensions and only allow a few. Any files that can execute code like .php,.html.py.js etc. you should filter out because they can potentially break into your file system, or worse. To make it more simple because t...
by Ehrmantraut
Mon Aug 26, 2013 2:27 pm
Forum: PHP
Topic: Temporary link Download
Replies: 30
Views: 16950

Re: Temporary link Download

You would just check if they left it blank. However, you need more validation for what you're doing because you aren't checking that what they're entering is actually a number. To accomplish what you're trying to do, first make sure that if they enter something that it's a number so it won't cause ...
by Ehrmantraut
Mon Aug 26, 2013 12:21 pm
Forum: PHP
Topic: Temporary link Download
Replies: 30
Views: 16950

Temporary link Download

Hi Folks, I am wondering how I would set a default period for a file to expire? At the moment you enter the number of minutes you want the file to be active, and after that set time the file expires. But, I want to add some functionality so that, by default, the file will expire after 10 minutes, sa...
by Ehrmantraut
Fri Aug 23, 2013 3:41 am
Forum: Code
Topic: Contact Form
Replies: 4
Views: 3319

Re: Contact Form

You should filter the email contents. I ran into a problem where an email provider I used had failed to filter JavaScript. Hidden fields are also editable. You should collect the ip by php once they submit the form. As for $_SERVER['REMOTE_ADDR'] being echoed unfiltered, Server variables are suppli...
by Ehrmantraut
Mon Aug 19, 2013 7:07 pm
Forum: Code
Topic: Contact Form
Replies: 4
Views: 3319

Re: Contact Form

Hey Temor,

Thanks, I appreciate the kind comments... feel free to copy and paste the code and change the styling if you wish, I have no problem with that it all. After all I posted it up there for people to use and modify it how they like! :)