/    Sign up×
Community /Pin to ProfileBookmark

Undefined index: uploadFile

this is the error message i have been fighting with: Undefined index: uploadFile.
My form file has this code to begin:

<form enctype=”multipart/form-data” action=”../php/modify_update.php” method=”post”>
<input type=”hidden” name=”MAX_FILE_SIZE” value=”2000000″ />

The actual form input part is this:

<td>Photo link:</td><td><?php echo $Photo_link ?></td><td class=”column3″>Select File:<input type=”file” name=”uploadFile” size=”40″><input type=”hidden” name=”MAX_FILE_SIZE” value=”25000″/></td>

My php file is this:

$target_path = “../plant_images/”;
$target_path2 = “../thumb_images”;
////////////////////////////////////////////////////////////////////////////
$target_path = $target_path . basename( $_FILES[‘uploadFile’][‘name’]);
//$target_path = $target_path . (basename(stripslashes( $_
FILES[‘uploadFile’][‘name’])));
///////////////////////////////////////////////////////////////////////////////
$Photo_link = $target_path;

I’m getting the error message on the: $target_path = $target_path …..

What really confuses me is that when I do a variable dump I see that the ‘uploadFile is assigned. Here is my dump:

array(23) { [“P_ID”]=> string(4) “1281” [“Date”]=> string(10) “2014-12-18” [“old_Date”]=> string(10) “2014-12-18” [“Action”]=> string(7) “test18a” [“old_Action”]=> string(8) ” test 18″ [“Pot_Number”]=> string(3) “18a” [“old_Pot_Number”]=> string(2) “18” [“Plant_Family”]=> string(3) “18a” [“old_Plant_Family”]=> string(11) “Apocynaceae” [“Plant_genus”]=> string(3) “18a” [“old_Plant_genus”]=> string(7) “Adenium” [“Plant_species”]=> string(3) “18a” [“old_Plant_species”]=> string(2) “18” [“blossom_description”]=> string(3) “18a” [“old_blossom_description”]=> string(3) “18 ” [“plant_description”]=> string(3) “18a” [“old_plant_description”]=> string(0) “” [“Plant_Name”]=> string(3) “18a” [“old_Plant_Name”]=> string(2) “18” [“uploadFile”]=> string(23) “DSCN3745 (1024×768).jpg” [“MAX_FILE_SIZE”]=> string(5) “25000” [“old_Photo_link”]=> string(39) “../plant_images/DSCN3748 (1024×768).jpg” [“update”]=> string(13) “Update Record” } the target pathe is: ../plant_images/try again here is the photo link

As usual, I’m sure it’s just a dumb error, but I’m not able to see it.
Thanks for any help you can give me.

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@NogDogDec 19.2014 — Did you add [B][FONT=Lucida Console]enctype="multipart/form-data"[/FONT][/B] to your <form> tag?
Copy linkTweet thisAlerts:
@szlykzauthorDec 19.2014 — Thanks yes.
Copy linkTweet thisAlerts:
@NogDogDec 19.2014 — Oops, looked for it, but somehow missed it. What I think we need then is a dump of $_FILES to see what's actually in there. Something like this should make it easier to read:

[code=php]
echo "<pre>".print_r($_FILES, 1)."<pre>";
[/code]
Copy linkTweet thisAlerts:
@szlykzauthorDec 19.2014 — This is what i see:

Array

(

)

Don't have a clue what this means. Sorry.
Copy linkTweet thisAlerts:
@szlykzauthorDec 19.2014 — I'm assuming this means that my $_Files is empty or not working yet my variable dump shows both uploadFiles are assigned. I guess my 68 year old brain doesn't understand what's happening.
Copy linkTweet thisAlerts:
@NogDogDec 19.2014 — Looks like no file is being uploaded at all. ?

The question is whether it's something malformed in the HTML, something preventing it on the web server, or something in your PHP config (or some other possibility I haven't thought of.) First simple thing I'd do is run the form page through the w3c validator.
×

Success!

Help @szlykz spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...