bigtimslim Posted April 9, 2008 Share Posted April 9, 2008 I have a php script that takes an image and edits it. I want the user to be able to select an image from his local machine. I thought to do this I would use input type file to get the path from the nice browse for file dialog. This works fine in IE, but with firefox i get errors. I printed the path to see what was going on and saw that all I was getting with firefox was the filename and extension.. without the full path. I need the full path, can anyone help? Link to comment https://forums.phpfreaks.com/topic/100259-solved-path-from-input-type-file-tag-ie-vs-firefox/ Share on other sites More sharing options...
ToonMariner Posted April 9, 2008 Share Posted April 9, 2008 code would help Link to comment https://forums.phpfreaks.com/topic/100259-solved-path-from-input-type-file-tag-ie-vs-firefox/#findComment-512787 Share on other sites More sharing options...
bigtimslim Posted April 10, 2008 Author Share Posted April 10, 2008 ok, code it is: <?php // Check if the form has been submitted: if (isset($_POST['submitted'])) { $errors = array(); // Check for file: if (empty($_POST['file'])) { $errors[] = 'You forgot to specify a file.'; } else { $f = $_POST['file']; } // Check for text: if (empty($_POST['text'])) { $errors[] = 'You forgot to enter text.'; } else { $t = $_POST['text']; } if (empty($errors)) { echo $f; exit(); } else { echo '<h1>Error!</h1> <p class="error">The following error(s) occurred:<br />'; foreach ($errors as $msg) { // Print each error. echo " - $msg<br />\n"; } echo '</p><p>Please try again.</p><p><br /></p>'; } } ?> <form action="bleh.php" method="post"> <p>Image File: <input type="file" name="file" id="file" value="<?php if (isset($_POST['file'])) echo $_POST['file']; ?>" /></p> <p>Image Text: <input type="text" name="text" size="15" maxlength="15" value="<?php if (isset($_POST['text'])) echo $_POST['text']; ?>" /></p> <p><input type="submit" name="submit" value="submit" /></p> <input type="hidden" name="submitted" value="TRUE" /> </form> When I run this in firerfox, I get: filename.jpg In IE if get: C:\\Users\\Tim\\Desktop\\filename.jpg Link to comment https://forums.phpfreaks.com/topic/100259-solved-path-from-input-type-file-tag-ie-vs-firefox/#findComment-513651 Share on other sites More sharing options...
ToonMariner Posted April 10, 2008 Share Posted April 10, 2008 You need to use the $_FILE array not $_POST in the processing script.... if you place print_r($_FILE); in your script you will see what I mean... Link to comment https://forums.phpfreaks.com/topic/100259-solved-path-from-input-type-file-tag-ie-vs-firefox/#findComment-513710 Share on other sites More sharing options...
bigtimslim Posted April 10, 2008 Author Share Posted April 10, 2008 ahhhh thank you Link to comment https://forums.phpfreaks.com/topic/100259-solved-path-from-input-type-file-tag-ie-vs-firefox/#findComment-513748 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.