Jump to content

avoinding direct access


etrader

Recommended Posts

I have a php form for uploading file as the action sends to upload.php. How I can avoid any kind of direct access to upload.php? I want to kill the php process at the first line without performing the remaining code (it is very critical for me as I have a counter), except calls coming from form.php.

Link to comment
Share on other sites

If you have named your submit button in your form then check for the $_POST['submit_button_name'] variable in exists in upload.php, eg

if(isset($_POST['submit']))
{
     // add the code for uploading the images here
}
else
{
    // display error or redirect back to form.php here
}

Link to comment
Share on other sites

Sorry, I didn't play close enough attention that you are going through an html form.

However, post variables and headers can be spoofed, so while either will work, they are not 100% reliable.

If you want to be 100% sure, you would need to use a server side cache such as APC.

Or stepping outside of php, I think the best solution is defining a rule in .htaccess.

Link to comment
Share on other sites

Is the upload from being drawn with php via a templating system or anything?  If so you could include a randomly generated string with the login form, which is stored in a database, then checked for in upload.php.  That would make it so that any submission would have to come from you upload form. 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.