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

  • Home
  • SEARCH
  • 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 4344772
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:56:39+00:00 2026-05-21T11:56:39+00:00

I have a very simple photo uploader which needs some bringing up to speed

  • 0

I have a very simple photo uploader which needs some bringing up to speed please

Firstly an echo appears when the page loads even tho there is nothing in the box?

if($_POST['upload']) {
     if($_FILES['image']['name'] == "")
     {
         #there's no file name return an error
         echo "\n<b>Please select a file to upload!\n</b>";
         exit;
     }
     #we have a filename, continue
}

#directory to upload to
$uploads = '/home/habbonow/public_html/other/quacked/photos';
$usruploads = 'photos';

#allowed file types
$type_array = array('image/gif','image/pjpeg','image/x-png');

if(!in_array($_FILES['image']['type'], $type_array))
{
    #the type of the file is not in the list we want to allow
    echo "\n<b>That file type is not allowed!\n</b>";
    exit;
}

the page output shows the uploading box but also echos “That file type is not allowed!” even when i haven’t clicked the button.

secondly what is the mime type for jpg please, as I have jpeg and pjpeg.

thanks, any help appreciated.


  • 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-21T11:56:39+00:00Added an answer on May 21, 2026 at 11:56 am

    I would also suggest putting everything in the POST block, otherwise it will be evaluated when the page is loaded no matter what.

    For mimetypes there is a method image_type_to_mime_type which lets you pass in a constant representing a given filetype and returns the proper mimetype for it, e.g.:

    $type_array = array(image_type_to_mime_type(), image_type_to_mime_type(IMAGETYPE_GIF), image_type_to_mime_type(IMAGETYPE_PNG), 'image/pjpeg');
    

    (Since pjpeg doesn’t have it’s own constant we can just add it manually)

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

Sidebar

Related Questions

I have some very simple javascript code that looks like this: var newWindow =
I have a very simple problem which requires a very quick and simple solution
I have a very simple WPF application in which I am using data binding
I have a very simple test page that uses XHR requests with jQuery's $.getJSON
We have a very simple page for displaying the records. Basically, it passes certain
i have this very simple php script: <?php require 'functions.php'; $token = some-number; $id
I have very simple: [PrincipalPermission(SecurityAction.Demand, Role = Administrator)] public partial class _Default : System.Web.UI.Page
i have very simple problem. I need to create model, that represent element of
I have very simple select like this: SELECT * FROM table WHERE column1 IN
I have very simple window where I have 2 buttons - one for cancel,

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.