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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:30:27+00:00 2026-06-12T19:30:27+00:00

The php file for the form is: <?php $allowedExts = array(jpg, jpeg, gif, png);

  • 0

The php file for the form is:

<?php
$allowedExts = array("jpg", "jpeg", "gif", "png");
$extension = end(explode(".", $_FILES["file"]["name"]));
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 60000)
&& in_array($extension, $allowedExts))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_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 "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";

if (file_exists("http://example.me/imgs/examples" . $_FILES["file"]["name"]))
  {
  echo $_FILES["file"]["name"] . " already exists. ";
  }
else
  {
  move_uploaded_file($_FILES["file"]["tmp_name"],
  "http://example.me/imgs/examples" . $_FILES["file"]["name"]);
  echo "Stored in: " . "http://example.me/imgs/examples" . $_FILES["file"]["name"];
  }
  }
  }
  else
  {
  echo "Invalid file";
  }
  ?>

This is straight forward enough, right? The html for the form is:

 <form action="img_upload.php" method="post" enctype="multipart/form-data">
 <label for="file">Filename:</label>
 <input type="file" name="file" id="file" /> 
 <input type="submit" name="submit" value="Submit"/>
 </form>

Also simple enough; correct? After submitting the image I get redirected to the img_upload.php file with the following text displayed:

 Upload: example.jpg
 Type: image/jpeg
 Size: 39.1943359375 Kb
 Temp file: C:\WINDOWS\Temp\php66.tmp
 Stored in: http://example.me/imgs/examplesexample.jpg

I’m getting frustrated like mad when I attempt to do simple tasks like this and no errors but no results either. I’ve already attempted adding “/” like imgs/examples/ within the php script and the only difference that it made was the following line after submitting is:

 Stored in: http://example.me/imgs/examples/example.jpg

Any ideas as to what I’m missing here. I have many other php scripts/mysql tables where images are being used and uploaded but for this simple task nothing. I’m using php 5 on a apache server testing on localhost. Thanks to all in advance for any assistance.

  • 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-12T19:30:28+00:00Added an answer on June 12, 2026 at 7:30 pm

    It’s unlikely that you can move a file to http://example.me/imgs/examples/. That’s not a path on your local system.

    You need to move it to a path like C:/path/to/web/root/filename.jpg instead.

    This is different than other places where the http protocol might work because you are writing a file, not reading a file.

    Your PHP script can’t really know that your http://example.me/imgs/examples/ directory is on the same server as itself; and it can’t figure out that by that URL you actually mean c:/apache/htdocs/imgs/examples/. (Imagine if you had Apache set up to map the above directory somewhere totally different- or your file system set up to actually link that directory somewhere else! PHP can’t possibly figure it out, it’s just too complicated.) While it might be possible in some situations to write to an HTTP protocol URL, it’s not really clear what that means, and the people who wrote PHP didn’t implement that. If it were written it would probably take the form of uploading the file to that URL as a POST which would require you to write code to accept the file, and then move it somewhere on your local system… which is exactly what you’re trying to do anyway.

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

Sidebar

Related Questions

My form action is set to a php file like this: <form name=addstudent action=includes/data.php?act=enquiry
<form action=form.php id=form> <input type=text name=name_1><input type=text name=city_1><input type=text name=country_1> <input type=text name=name_2><input type=text
In this question I asked how to POST to a php file form a
I have a php file that contains a form (which contains 2 input boxes
i have an form which will send some data to an php file ,
I am trying to include a .php file that will generate a form for
I am using AJAX to send form data to a server php file that
The following sends values entered through a form to a php file: $.ajax ({
I am generating a rss(xml) output form a php file. I have got a
I'm trying to call a function from a form within the same .php file,

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.