Jump to content

Recommended Posts

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.

 

 

Link to comment
https://forums.phpfreaks.com/topic/36753-uploading-specific-file/
Share on other sites

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! :)

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!";
}
?>

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.