Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5843791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:12:13+00:00 2026-05-22T12:12:13+00:00

I have written a simple php script for allowing a user to download a

  • 0

I have written a simple php script for allowing a user to download a file after submitting his data through a form. It was working fine for a few days and today this error message appeared

Warning: Cannot modify header information - headers already sent by (output started at /home/psitinc/public_html/mymail.php:6) in /home/psitinc/public_html/mymail.php on line 47

Warning: Cannot modify header information - headers already sent by (output started at /home/psitinc/public_html/mymail.php:6) in /home/psitinc/public_html/mymail.php on line 48

Warning: readfile(/public_html/downloads/gadVibroScreenSingleMotor.pdf) [function.readfile]: failed to open stream: No such file or directory in /home/psitinc/public_html/mymail.php on line 49

When I googled about the error they told me to check for whitespaces which I have checked and there are none.

Also the file download is not working even if I provide absolute path(/public_html/downloads/gadSingleDeckScreen.pdf) it says file not found on the server

<?php 
ini_set('session.bug_compat_warn', 0);
session_start();
$id = isset($_SESSION['id']) ? (int)$_SESSION['id'] : null;
$name = isset($_SESSION['name']) ? (int)$_SESSION['name'] : null;
print_r($_SESSION);
$name = $_POST["name_first"];
    if (empty($name))
        {
            echo "<h3>Enter your name</h3>";
            exit;
        }
$mail = $_POST['email'];
    if (empty($mail))
        {
            echo "<h3>Email field required</h3>";
            exit;
        }
    elseif(!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/", $mail)) 
        {
            echo"<h3>Sorry the email address you entered is invalid please try again</h3>";
            exit;
        }
$number = $_POST['phone_number'];
$email_message = "First name: {$name}   Email ID:  {$mail}      Number   {$number} ";
    mail('vinferrari@gmail.com', 'Form Response', $email_message);  
        if (empty($name) || empty($mail) || empty($number))
                {
                        echo "<h3>Enter all fields</h3>  ";
                        $url = htmlspecialchars($_SERVER['HTTP_REFERER']);
                        header("Location: $url");
                        exit;
                }
            elseif ($id==1002)
                {
                 header('Content-type: application/octet-stream');
                 header('Content-Disposition: attachment; filename="gadSingleDeckScreen.pdf"');
                 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                 readfile('gadSingleDeckScreen.pdf');
                 exit;
                }
            ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:12:13+00:00Added an answer on May 22, 2026 at 12:12 pm

    The path is very likely not /public_html/downloads/gadVibroScreenSingleMotor.pdf. A leading / means the root of your filesystem.

    Did you mean one of these?

    • downloads/gadVibroScreenSingleMotor.pdf
    • /var/www/html/public_html/downloads/gadVibroScreenSingleMotor.pdf
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a very very very simple!! script in php. header redirection not
So I have a script (written in PHP) that posts the user input of
I have written a simple file upload script but it gives me the error
I have some code I've written in PHP for consuming our simple webservice, which
I have written a simple brainfuck interpreter in MATLAB script language. It is fed
I have written a simple CRUD form which has one select list. However the
I have written a simple jQuery.ajax function which loads a user control from the
I have written a very simple bash script to help me migrate from dev
I have a simple script written to process received email. Here are the tested
I have written a script using my local PHP 5.3 installation making use of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.