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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.