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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:47:13+00:00 2026-05-30T02:47:13+00:00

When I go to myserver index and upload and image from there using the

  • 0

When I go to myserver index and upload and image from there using the interface, it works fine. But as soon as I try to enter the path myself, like:

http://myserver/upload.php?image['name']=F:\Bilder\6.jpg

it gives me an error that all fields are required. But I have to upload images like this, because I plan to implement it in an app that I’m making. Thing is, that I’m not that well acquainted with php.

here is the upload.php

<?php
session_start();

require("includes/conn.php");


function is_valid_type($file)
{

$valid_types = array("image/jpg", "image/jpeg", "image/bmp", "image/gif", "image/png");

if (in_array($file['type'], $valid_types))
    return 1;
return 0;
}

function showContents($array)
{
echo "<pre>";
print_r($array);
echo "</pre>";
}

$TARGET_PATH = "images/";

$image = $_FILES['image'];

$image['name'] = mysql_real_escape_string($image['name']);

$TARGET_PATH .= $image['name'];

if ( $image['name'] == "" )
{
$_SESSION['error'] = "All fields are required";
header("Location: index.php");
exit;
}

if (!is_valid_type($image))
{
$_SESSION['error'] = "You must upload a jpeg, gif, or bmp";
header("Location: index.php");
exit;
}

if (file_exists($TARGET_PATH))
{
$_SESSION['error'] = "A file with that name already exists";
header("Location: index.php");
exit;
}

if (move_uploaded_file($image['tmp_name'], $TARGET_PATH))
{
$sql = "insert into Avatar (filename) values ('" . $image['name'] . "')";
$result = mysql_query($sql) or die ("Could not insert data into DB: " .     mysql_error());

exit;
}
else
{
header("Location: index.php");
exit;
}

?>

and the index.php

                <?php
                if (isset($_SESSION['error']))
                {
                    echo "<span id=\"error\"><p>" . $_SESSION['error'] . "</p></span>";
                    unset($_SESSION['error']);
                }
                ?>
                <form action="upload.php" method="post" enctype="multipart/form-data">
                <p>

                    <label>Avatar</label>
                    <input type="file" name="image" /><br />
                    <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
                    <input type="submit" id="submit" value="Upload" />
                </p>
  • 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-30T02:47:14+00:00Added an answer on May 30, 2026 at 2:47 am

    the problem lies in

    if ( $image['name'] == "" )
    

    $image has no value there.

    You are doing a get request so if you would like to know what the image variable is you should use

    $_GET['image']
    

    Another thing is that you are doing $image = $_FILES[‘image’];

    $_FILES will only be available from a post request.
    Uploading files can not be done in the way you are doing now by a parameter from a GET request.

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

Sidebar

Related Questions

I'm using plupload to upload files to my server ( http://www.plupload.com/index.php ), however I
Greetings, I'm uploading an image to my server using the following code: http://cocoadev.com/index.pl?HTTPFileUploadSample However,
There is index.php and logo.gif files in my server. I need to change the
I tried using this: mvn dependency:get -DrepoUrl=http://myserver/artifactory -Dartifact=com.mypackage:my-package-name:1.0.0 However it just downloaded the pom.xml
I have a simple upload form working in PHP (works in web) and also
I typically refer to any assets on my site using absolute path so that
I need to perform a HTTP GET from PHP. More specifically, from within /index.php
I am, using a cakephp form helper to upload images to my server. The
I have Javascript updating my URI as below: /index.php?page=list#page=news But I would like to
I have a simple Rails 3.1.rc6 app that I'm using to try to test

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.