datoshway Posted April 6, 2011 Share Posted April 6, 2011 I have one input upload and need it to go to two directories here is my upload code that handles the move_upload_file portion. move_uploaded_file($_FILES['fillPDF']['tmp_name'], $strNewsPath . $strFilename); Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/232906-upload-to-multiple-directories/ Share on other sites More sharing options...
Psycho Posted April 6, 2011 Share Posted April 6, 2011 After you move the file to one location, copy it to the second location using copy(): http://php.net/manual/en/function.copy.php Link to comment https://forums.phpfreaks.com/topic/232906-upload-to-multiple-directories/#findComment-1197916 Share on other sites More sharing options...
datoshway Posted April 6, 2011 Author Share Posted April 6, 2011 Hey thanks for that. Still not working. Here is my snippet. Please let me know what you see wrong here? if ($intContentID > -1) { if (($_FILES['fillPDF']['error'] == UPLOAD_ERR_OK) && ($_FILES['fillPDF']['error'] != UPLOAD_ERR_NO_FILE)) { $arrPathInfo = pathinfo($_FILES['fillPDF']['name']); $strFilename = md5(uniqid(rand(), true)) . "." . strtolower($arrPathInfo['extension']); move_uploaded_file($_FILES['fillPDF']['tmp_name'], $strNewsPath . $strFilename); copy($_FILES['fillPDF']['tmp_name'], $strNewsPath2 . $strFilename); } Link to comment https://forums.phpfreaks.com/topic/232906-upload-to-multiple-directories/#findComment-1197920 Share on other sites More sharing options...
datoshway Posted April 6, 2011 Author Share Posted April 6, 2011 Found out my problem, I think with the hash md5 happening before the copy it didn't have a file name for it. I changed it around and seems to be working now. if ($intContentID > -1) { if (($_FILES['fillPDF']['error'] == UPLOAD_ERR_OK) && ($_FILES['fillPDF']['error'] != UPLOAD_ERR_NO_FILE)) { $arrPathInfo = pathinfo($_FILES['fillPDF']['name']); $strFilename = md5(uniqid(rand(), true)) . "." . strtolower($arrPathInfo['extension']); move_uploaded_file($_FILES['fillPDF']['tmp_name'], $strNewsPath . $strFilename) && copy($strNewsPath . $strFilename , $strNewsPath2 . $strFilename); } Link to comment https://forums.phpfreaks.com/topic/232906-upload-to-multiple-directories/#findComment-1197950 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.