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

Related Questions

I decided to make a system for a client using Castle ActiveRecord , everything
We decided to use the minimumRequiredVersion in our clickOnce application manifest, and now when
Ive decided that I really dont like microsoft and their ways. Please could you
I've been researching memory mapped files for a project and would appreciate any thoughts
I decided to try http://www.screwturn.eu/ wiki as a code snippet storage utility. So far
I decided to install APC to speed up the site that I work for.
I decided to use log4net as a logger for a new webservice project. Everything
I decided to learn C++ (I program in C at work), and I have
I decided to teach myself assembly language. I have realized that my program will
I decided to change a utility I'm working on to use a tabpage. When

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.