Jump to content

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

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.