Jump to content

[SOLVED] Register Global problem (image upload)


ayok

Recommended Posts

Hi,

 

I have a problem working with register global = Off. I used to set it "on" when I worked on my scripts in my local server. However, i heard that it's not recommended. So now I add some $_GET, $_POST, etc. Mostly I can do, but now I have a problem with uploading script. Especially, on admin pages.

 

I upload the image with a simple script:

<?php
include "../../connection/db.php";
echo "<FORM enctype=MULTIPART/FORM-DATA METHOD=POST ACTION=input_pic.php>";
echo "Upload picture:<input type=file name=[u]fupload[/u]> ";
echo "<INPUT TYPE=SUBMIT VALUE=add>";
}?>

With register global = On, I can just write the input_pic.php like this:

<?php
include "../../connection/db.php";
$input=mysql_query("INSERT INTO gallery(image) VALUES('$fupload_name')") or die(mysql_error());
$direktori_file = "../../gallery/images/original/$fupload_name";
if ($fupload_type != "image/pjpeg" AND 
$fupload_type != "image/jpeg")
{
    echo "Type file <b>$fupload_name</b> is $fupload_type<br>";
    echo "Insert image is failed<br>";
}
elseif (!move_uploaded_file($fupload, "$direktori_file"))
{
    echo "Upload process failed!<br>";
    echo "<a href=add_pic.php>Upload again</a><br>";
}

The name fupload can be $fupload, $fupload_name, or $fupload_type.

 

However, with register global = off, the script doesn't work. I've tried to insert

$fupload=$_GET[fupload]

, but it doesn't work either.

 

Could anybody help me out here?

 

Thank you,

ayok

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.