Skip to content

Tag: php

How can I allow a download to pause/resume?

Normally, when I want to allow a user to download a file without revealing the exact location, I just use something like this to let them download the file: But if they are using a modern browser or other download client, and they pause the download and try to resume it, the script (assuming they are still au…

Return a PHP page as an image

I am trying to read a image file (.jpeg to be exact), and ‘echo’ it back to the page output, but have is display an image… my index.php has an image link like this: and my php script does basically this: 1) read 1234.jpeg 2) echo file contents… 3) I have a feeling I need to return the …

Sanitizing form data in PHP

Is it possible to sanitize all input sent by one method in PHP by simply doing and then access elements of $var as I would have of $_POST ? Answer I don’t think you can call mysql_real_escape_string on an array. But this would work array_map works by calling the function named in quotes on every element…

How to base64-decode large files in PHP

My PHP web application has an API that can recieve reasonably large files (up to 32 MB) which are base64 encoded. The goal is to write these files somewhere on my filesystem. Decoded of course. What would be the least resource intensive way of doing this? Edit: Recieving the files through an API means that I …

PHP Pass variable to next page

It seems pretty simple but I can’t find a good way to do it. Say in the first page I create a variable And the form’s action for that page is “Page2.php”. So in Page2.php, how can I have access to that variable? I know I can do it with sessions but I think it’s too much for a sim…

How to access the form’s ‘name’ variable from PHP

I’m trying to create a BMI calculator. This should allow people to use either metric or imperial measurements. I realise that I could use hidden tags to solve my problem, but this has bugged me before so I thought I’d ask: I can use $_POST[‘variableName’] to find the submitted variable…