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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T23:30:53+00:00 2026-05-28T23:30:53+00:00

I upload a file to a server by filling out a form. The file

  • 0

I upload a file to a server by filling out a form. The file should be uploaded and a record should be created with many data in the mysql table. This is how I specify the upload path:

$upload_path = "upload/";

In the public_html folder I have all the necessary .php files and the precreated upload folder as well. The upload is successful, mysql table has one new record, everything seems to be fine, except I cannot see the file in the public_html/upload folder.

I know this must be a rookie question, I need help.

   $allowed_filetypes = array('.jpg','.gif','.bmp','.png','.tif','.doc','.docx','.xls','.xlsx','.pdf','.psd');
     $filename = $_FILES['file']['name'];
     $max_filesize = 524288; //0.5MB
     $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1);
     //$upload_path = "C:/wamp/www/upload/";    //'./files/';
     $upload_path = "upload/";
      if(!in_array($ext,$allowed_filetypes))
      {
        die('The file you attempted to upload is not allowed or you haven not selected any files!');
      }
      if(filesize($_FILES['file']['tmp_name']) > $max_filesize)
      {
        die('The file you attempted to upload is too large.');
      }
      if(!is_writable($upload_path))
      {
        die('Invalid or non-writable folder');
      }


      if (file_exists($upload_path . $_FILES["file"]["name"]))
      {
        //echo $_FILES["file"]["name"] . " already exists. ";
    ?>
          <script type="text/javascript">
          alert('File with this name already exists!');
          </script>
    <?php

      }
      else
      {
        if(move_uploaded_file($_FILES['file']['tmp_name'],$upload_path . $filename))
        {
            ?>
          <script type="text/javascript">
            alert('Successful upload!');
          </script>
    <?php   
    }
//getting variables, insert into statement -> record added to table, this part is fine
    }
    ?>
  • 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-28T23:30:54+00:00Added an answer on May 28, 2026 at 11:30 pm

    could also be that the permissions on the folder are not set so that the file can be created. This is done one of 2 ways.

    1) If you have root access you can let the user who runs the web server own that directory with a chown command.

    chown username dirpath
    

    2) If you do not have root access, you must make the directory world writable.

    chmod 777 dirpath
    

    Try this code….

    $uploads_dir = $_SERVER['DOCUMENT_ROOT'] . '/uploads';
    
    if(is_dir($upload_dir) && is_writable($upload_dir))
    {
      // put your code to handle uploaded file here
    }
    else
    {
        echo "Sorry the upload file does not exist or I can not save the file there due to directory permissions";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to upload a file to the server using a HTTP multipart form
In Flex i want to upload a particular file to server form local system.how
i want to upload the sound file (.ogg) in server. But it should write
In my web application I need to upload file to the server. This file
I want to create a simple file upload server. The server should be able
Possible Duplicate: upload a file to server without using a form? I'am able to
When I am using a form containing <input id=myFile type=file runat=server /> to upload
Is it possible to upload a file to another server or pass a file
I was wondering the best way to upload file to a web server in
I want to upload a file to a ftp server programmatically (C++). If the

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.