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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:58:54+00:00 2026-06-02T17:58:54+00:00

I want to upload files in PHP. I wrote <form target=_self enctype=multipart/form-data> <input type=file

  • 0

I want to upload files in PHP. I wrote

<form target="_self" enctype="multipart/form-data">
<input type="file" name="file" id="file" />
<input name="submit" type="submit" value="submit" />
</form>
<?php

if ($_FILES["file"]["error"] > 0)
  {
  echo "Error: " . $_FILES["file"]["error"] . "<br />";
  }
else
  {
  echo "Upload: " . $_FILES["file"]["name"] . "<br />";
  echo "Type: " . $_FILES["file"]["type"] . "<br />";
  echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
  echo "Stored in: " . $_FILES["file"]["tmp_name"];
  }

?>

but it’s not working. Files are not visible to me, that where they are going?

  • 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-06-02T17:58:55+00:00Added an answer on June 2, 2026 at 5:58 pm

    You are a long way from a working script

    You can try

    <?php
    $output = array ();
    $errors = array ();
    $savePath = "uploaded"; // PATH to upload images
    $allowedExt = array (
            "png",
            "jpg" 
    );
    if (isset ( $_FILES ['file'] ) && $_FILES ["file"] ["error"] == UPLOAD_ERR_OK) {
    
        $fileName = $_FILES ['file'] ['name'];
        $fileSize = $_FILES ['file'] ['size'];
        $fileTemp = $_FILES ['file'] ['tmp_name'];
        $fileType = $_FILES["file"]["type"] ;
        $fileExt = pathinfo ( $fileName, PATHINFO_EXTENSION );
        $fileExt = strtolower ( $fileExt );
    
        //var_dump($fileExt);
    
        if (!in_array ( $fileExt, $allowedExt )) {
            $errors [] = "Invalid File Extention";
        }
    
        if ($fileSize > 800*1024) {
            $errors [] = "File Too large";
        }
    
        if (! is_writable ( $savePath )) {
            $errors [] = "File Destination not writeable";
        }
    
        $fileDst = $savePath . DIRECTORY_SEPARATOR . $fileName;
        $filePrifix = basename ( $fileName, "." . $fileExt );
        $i = 0;
        while ( file_exists ( $fileDst ) ) {
            $i ++;
            $fileDst = $savePath . DIRECTORY_SEPARATOR . $filePrifix . "_" . $i . "." . $fileExt;
    
        }
        if (count ( $errors ) == 0) {
            if (@move_uploaded_file ( $fileTemp, $fileDst )) {
                $output['STATUS'] = "OK";
                $output['TYPE'] = $fileType;
                $output['Size'] = $fileSize;
                $output['Destination'] = $fileDst;
            } else {
                $errors [] = "Error Saving File";
            }
    
        }
    
    
        if(count($errors) > 0)
        {
            echo "<h2>Upload Error</h2>" ;
    
            foreach ($errors as $error)
            {
                echo $error , "<br/>" ;
    
            }
        }
        else
        {
            echo "<h2>File  Uploaded</h2>" ;
            foreach ($output as $key => $value)
            {
                echo $key , ":" , $value , "<br/>" ;
            }
    
        }
    }
    
    ?>
    <br/>
    <br />
    <form method="post" target="_self" enctype="multipart/form-data">
        <input type="file" name="file" id="file" /> <input name="submit"
            type="submit" value="submit" />
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to upload and store video files to my server using PHP. Could
I use the PHP language for file upload and want to know that the
i have the form, and i want to upload two files. here is the
I want to upload data, images, txt files, pdf documents , etc. Im using
I want to upload files with PHP and i use move_uplload_files to copy them
I want to upload file with have only file path in php. Can anyone
I want to upload files using PHP but the problem is that I don't
I want to allow uploads of very large files into our PHP application (hundred
I want to upload files directly to IIS7 (in this case I am using
i want to upload two files. here is the script <? ini_set('memory_limit', 400M); ini_set('file_uploads',

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.