Jump to content

Upload the file twice


jagguy

Recommended Posts

I want to copy an uploaded file to 2 locations instead of 1. I try to move the uploaded file to another directory again, but it fails.

I tried to use copy copy( $_FILES['uploadedfile']['name'],$ff); and I tried
copy( $_FILES['uploadedfile']['tmp_name'],$ff).

I don't know how to run a script and copy 1 file from 1 location to another.
I thought this would be easy to do but I can't do it.

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'],$target_path.$filename))
{
echo "..>";
}

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'],$target_path."thumbs\".$filename))
{
echo "..>";
}
Link to comment
https://forums.phpfreaks.com/topic/28396-upload-the-file-twice/
Share on other sites

Look at these lines: move_uploaded_file()

[code]<form action="" method="post" enctype="multipart/form-data">
<p>Pictures:
<input type="file" name="pictures[]" />
<input type="submit" value="Send" />
</p>
</form>

<?php
foreach ($_FILES["pictures"]["error"] as $key => $error) {
  if ($error == UPLOAD_ERR_OK) {
      $tmp_name = $_FILES["pictures"]["tmp_name"][$key];
      $name = $_FILES["pictures"]["name"][$key];
      move_uploaded_file($tmp_name, "data/location1/$name");
      move_uploaded_file($tmp_name, "data/location2/$name");
  }
}
?> [/code]
Link to comment
https://forums.phpfreaks.com/topic/28396-upload-the-file-twice/#findComment-129957
Share on other sites

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.