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 575435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:56:25+00:00 2026-05-13T13:56:25+00:00

so i decided against using uploadify as i could not get any help on

  • 0

so i decided against using uploadify as i could not get any help on it. i’ve been now trying to implement a simpler solution. but unfortunately i cannot seem to process the upload code on a single page without receiving the following error:

Warning: fopen() [function.fopen]:
Filename cannot be empty in
C:\xampp\htdocs\speedycms\manageclient.php
on line 205

Warning: fread() expects parameter 1
to be resource, boolean given in
C:\xampp\htdocs\speedycms\manageclient.php
on line 206

Warning: fclose() expects parameter 1
to be resource, boolean given in
C:\xampp\htdocs\speedycms\manageclient.php
on line 208 Error, query failed

this is the code i’ve been trying to get to work… can you suggest any means of getting it all to work on a single page rather than splitting it up into two apart from ajax (im not too familiar with that)… its all on a single page

any help would be appreciated!

         <!-- upload file --->

             <?php
                     if (array_key_exists('uploadfile',$_POST)) {
    $fileName = $_FILES['userfile']['name'];
    $tmpName  = $_FILES['userfile']['tmp_name'];
    $fileSize = $_FILES['userfile']['size'];
    $fileType = $_FILES['userfile']['type'];

    $fp      = fopen($tmpName, 'r');
    $content = fread($fp, filesize($tmpName));
    $content = addslashes($content);
    fclose($fp);

    if(!get_magic_quotes_gpc())
    {
        $fileName = addslashes($fileName);
    }

    $uploadQry = "INSERT INTO upload (name, size, type, content ) ".
    "VALUES ('$fileName', '$fileSize', '$fileType', '$content')";

    mysql_query($uploadQry) or die('Error, query failed'); 

    echo "<br>File $fileName uploaded<br>";
    exit;
                     }
    ?>

<form method="post" action="<?php echo $_SERVER['PHP_SELF'] . '?id=' . intval($client_id); ?>">
    <p>
         <b>File Upload</b></p>
    <p>
<input type="hidden" name="MAX_FILE_SIZE" value="2000000">
<input name="userfile" type="file" id="userfile"><BR />
               <input type="hidden" name="uploadfile" value="1"/> 
<input name="upload" type="submit" id="upload" value=" Upload ">
    </p>
    <p>      <a href="#viewFiles" class="form" rel="facebox">View files</a>

    </p>
    <div id="viewFiles" style="display:none;" rel="facebox"> 
      <div style="width:300px; height: 300px;"></div></div></form>
  • 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-13T13:56:26+00:00Added an answer on May 13, 2026 at 1:56 pm

    You need to set the correct encoding of your form to enable file uploads:

    <!-- The data encoding type, enctype, MUST be specified as below -->
    <form enctype="multipart/form-data" action="__URL__" method="POST">
        ...
    </form>
    

    Edit: Filename cannot be empty is telling you that you have not specified the file name in your first call to fopen – you’re passing in $tmpName to that method, which is assigned from $_FILES['userfile']['tmp_name'].

    The only reason I can think of for $_FILES['userfile']['tmp_name'] to be empty is that you haven’t actually uploaded a file?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 402k
  • Answers 402k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Your AppInstance class is probably loaded separately by each custom… May 15, 2026 at 4:56 am
  • Editorial Team
    Editorial Team added an answer The full edition Profiler can connect to Express and it… May 15, 2026 at 4:56 am
  • Editorial Team
    Editorial Team added an answer One trick I've used is to run the program under… May 15, 2026 at 4:56 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.