Jump to content

trouble with $_FILES


onlyican

Recommended Posts

Hey

I have a form, which allows someone to edit a product on there website
On the form, is 2 file fields
One for the PDF
One for the Photo

The way I am doing this, is checking if the $_FILES is set
for example, a snippet from the form is
[code]
<?php
echo ".<input type='hidden' name='old_pdf' value='".$old_pdf."' />\n"
."<input type='file' name='new_pdf' />\n";
?>
[/code]

then I am checking this by doding something like

[code]
if(isset($_FILES["new_pdf"]["name"]){
//Upload PDF
$new_pdf = $_FILES["new_pdf"]["name"];
}else{
$new_pdf = $_POST["old_pdf"];
}
[/code]

BUT
the form is coming up saying that $_FILES["new_pdf"]["name"]
is set, although I am not trying to upload a file

Anyone know a way to check if someone is tryna upload a file or not
Link to comment
https://forums.phpfreaks.com/topic/26687-trouble-with-_files/
Share on other sites

I dont understand what your trying to do,

$_FILES["new_pdf"]["name"] is just going to return the name of a file you have selected with your input if a file is selected, there is nothing to check because you are not actually doing anything to the input value once you have it.
Link to comment
https://forums.phpfreaks.com/topic/26687-trouble-with-_files/#findComment-122091
Share on other sites

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.