kron Posted February 2, 2007 Share Posted February 2, 2007 Greetings, Im trying to upload a specific file without having to click "Browse" and choose the file manually, but not having much luck. i first tried the obvious... <input type="file" name="file" id="file" value="C:\test.txt" /> but this does not work, im a little rusty on my php now (Not done any for 6 odd months) so any help would be appreciated. ive had a look at manually entering the required info into $_FILES but so far not had much luck. What im trying to accomplish is to try and create an uploader which would test a card reader, it would try and upload an image from each of the media types, and if it succesfully uploads, i would know that media slot is working. Any help would be appreciated. Kron. Quote Link to comment https://forums.phpfreaks.com/topic/36753-uploading-specific-file/ Share on other sites More sharing options...
HuggieBear Posted February 2, 2007 Share Posted February 2, 2007 There's nothing wrong with that code, and the specifications state that you can use the 'value=' attribute to set the default file, to circumvent the 'Browse' button. So what's the actual problem you're having? Regards Huggie Quote Link to comment https://forums.phpfreaks.com/topic/36753-uploading-specific-file/#findComment-175298 Share on other sites More sharing options...
kron Posted February 2, 2007 Author Share Posted February 2, 2007 the problem im having is that the piece of code you said should work, doesnt work. Upon loading the page i would expect the form to have the value in it, but it doesnt, if i go ahead anyway and click upload, i get the error that no file present. the upload script works, it can upload files perfectly if i select browse and choose the file that way. Thanks **And grats on the 1500 post milestone! Quote Link to comment https://forums.phpfreaks.com/topic/36753-uploading-specific-file/#findComment-175303 Share on other sites More sharing options...
kron Posted February 2, 2007 Author Share Posted February 2, 2007 what the entirity of my code looks like is... The form.. uploader.php <html> <body><form action="upload_file.php" method="post" enctype="multipart/form-data"> Filename: <input type="file" name="file" id="file" value='C:\Misc\b.gif'> <br /> <input type="submit" name="submit" value="Submit" /> </form></body> </html> the upload script.. upload_file.php <?php $target_path = "upload/"; $target_path = $target_path . basename( $_FILES['file']['name']); if(move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['file']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/36753-uploading-specific-file/#findComment-175318 Share on other sites More sharing options...
kron Posted February 2, 2007 Author Share Posted February 2, 2007 further investigation tells me it is impossible. It seems theirs too big a security risk to allow people to do this, because you would be able to aquire any file from someones system without them knowing. Seems it back to the drawing board for me Quote Link to comment https://forums.phpfreaks.com/topic/36753-uploading-specific-file/#findComment-175343 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.