Posting Images help

I am a little stuck, as pretty much everyone on here :stuck_out_tongue:

I am wanting to create a image uploader that adds the user information etc to the sql, I have made the code before (and it works) on another page, but for some reason it isn’t allowing it to work on this page.

I have looked over the code two or three times and can’t find the error. Can anyone help please?

[php]if($_POST[‘fileUpload’] == ‘Upload’) {
foreach($_POST as $key => $value) {
$data[$key] = filter($value);
}

if ($_FILES['photo'] == '') {
} else {

$prefix = substr ( md5(uniqid(rand(),1)), 3, 10)

$target = “files/”.$prefix."_";
$target = $target . basename($FILES[‘photo’][‘name’]);
$pic = ($prefix."
".$_FILES[‘photo’][‘name’]);
if(move_uploaded_file($_FILES[‘photo’][‘tmp_name’], $target)) {

mysql_query (“INSERT INTO uploaded
(user_id,username,upload_title,upload_name)
VALUES (’$_SESSION[user_id]’,’$_SESSION[user_name]’,’$data[title]’,’$pic’)”);

$msg[] = “File Sucessfully Uploaded!”;

} else { echo “Error - Conact Administration Quote Code: FLERROR42”; } } }
[/php]
The Form for this code is the following:::
[php]

Upload:
Title:
File Type:
[/php]

Additional Information::
The file “files/” does exsist, the sql table “uploaded” is also in my sql database and the sql database information is defined earlier within the code (not including for saftey)

if anyone can spot my error I would be forever grateful Thanks.

Did you forget this in your form tag ?

enctype=“multipart/form-data”

I did yes, I will test that and find out.

It did work, don’t believe it was something that simple >_>

Thanks for your help Quentin

Sponsor our Newsletter | Privacy Policy | Terms of Service