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
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

 

Link to comment
Share on other sites

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
Share on other sites

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.