johnhenry Posted October 23, 2013 Share Posted October 23, 2013 I wonder if anyone knows whether this is possible, Sorry if this should be in the html section, but the rest is a php script. I have to upload a file which always stays the same, When it is processed for upload I change the name according to some other criteria. That is all done and working, but what I would like to do is that the person doing the upload does not have to choose the file each time. I tried putting in a value attribute into the form field like this.. <input type="file" name="filename" value="55656-Oct21-2.pdf" size="20"> It seems to ignore the value and processes nothing. Choosing the file works OK. I just want them to be able to press 'Submit' without looking for it. Still no joy. Ideas would be appreciated Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted October 23, 2013 Share Posted October 23, 2013 You can't automatically attach a file to a file input. The user will always have to choose the file to be uploaded. Quote Link to comment Share on other sites More sharing options...
johnhenry Posted October 23, 2013 Author Share Posted October 23, 2013 That was my gut-feeling, but I had to ask. Many thanks for the quick response. Quote Link to comment Share on other sites More sharing options...
Barand Posted October 23, 2013 Share Posted October 23, 2013 (edited) Store the file on the server if it always stays the same then copy it (renaming at same time) when form is submitted Edited October 23, 2013 by Barand Quote Link to comment Share on other sites More sharing options...
johnhenry Posted October 23, 2013 Author Share Posted October 23, 2013 I didn't think of that. Sounds like a good idea. Thanks Quote Link to comment Share on other sites More sharing options...
johnhenry Posted October 23, 2013 Author Share Posted October 23, 2013 I tried out the renaming idea, and I put the renamed file into a new folder. It works well but the problem is that it deletes the master file. How can I do this without losing the original? Here is what I did. rename("pdf/55656-Oct21-2.pdf", "pdfs/55656.pdf"); Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted October 23, 2013 Share Posted October 23, 2013 rename will rename the file. Use copy instead copy('path/to/oldfilename', 'path/to/newfilename'); Quote Link to comment Share on other sites More sharing options...
johnhenry Posted October 23, 2013 Author Share Posted October 23, 2013 OK. I want it renamed but I guess it will be a two stage operation. Copy first then rename the copy. I'm a bit shaky on file handling but with your help it is getting better. Thanks Quote Link to comment Share on other sites More sharing options...
Barand Posted October 23, 2013 Share Posted October 23, 2013 Just give it the new name when you copy it. Quote Link to comment Share on other sites More sharing options...
Solution johnhenry Posted October 23, 2013 Author Solution Share Posted October 23, 2013 Great. I did it and it works exactly how I want it. I appreciate your help. Quote Link to comment 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.