Jump to content

Automatic file upload to a form


DataRater

Recommended Posts

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

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

 

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

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.