DataRater Posted March 12, 2010 Share Posted March 12, 2010 PHP 5 I'm currently working on downloading a file into my server from an HTML form, processing it, and automatically uploading it to the calling HTML page. This is an example of the behavior I want although this is not my site. http://images.my-addr.com/resize_jpg_online_tool-free_jpeg_resizer_for_web.php Notice how when the go button is pressed the file is resized and automatically uploaded. I need to know how to get that automatic upload to work. Stephen Link to comment https://forums.phpfreaks.com/topic/195025-automatic-file-upload-to-a-form/ Share on other sites More sharing options...
DataRater Posted March 12, 2010 Author Share Posted March 12, 2010 This is how you do it... $Filename='Picture.jpg'; header('Content-disposition: attachment; filename='.$Filename); header('Content-type: application/octet-stream'); readfile($MyGlobals['WatermarksDirectory'].$Filename); Stephen Link to comment https://forums.phpfreaks.com/topic/195025-automatic-file-upload-to-a-form/#findComment-1025259 Share on other sites More sharing options...
bag Posted March 13, 2010 Share Posted March 13, 2010 here is how I upload a form. Contact_Form.html <form method="POST" action="Send_Contact_Form.php" enctype="multipart/form-data"> <input type="text" name="email" size="40" value=""> Please enter your EMail address.<br><br> <TEXTAREA NAME="message" COLS=80 ROWS=10 WRAP=SOFT></TEXTAREA><br><br> <input type="file" name="file" size="40" value=""> Any file you want to attach.<br><br> <input type="submit" value="Send Message" name="submit"> </form> Then Send_Contact_Form.php if ( $file_name != '' ) { $result = @copy ( $file, "$tmp_dir$file_name" ); where tmp_dir is defined by me to be the directory I want it to go to. Don't let it default if you can avoid it. $file is supplied and $filename is created for it by PHP. Note the enctype in the form. It won't work without it Link to comment https://forums.phpfreaks.com/topic/195025-automatic-file-upload-to-a-form/#findComment-1025713 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.