jaxdevil Posted April 10, 2008 Share Posted April 10, 2008 I have a script that creates a folder on the server, then uploads files to it. The problem is the upload is not going into the right directory. Here are the two scripts. When I upload them the files go into the directory /ebay instead of the directory /ebay/1 (in the case that ebay_task=1) First Page: <HTML> <HEAD> <TITLE></TITLE> <META name="description" content=""> <META name="keywords" content=""> <META name="generator" content="CuteHTML"> </HEAD> <BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080"> Creating Folder <?=$ebay_task;?><br> <br> <?php mkdir("./ebay/$ebay_task", 0777); ?> <br> <table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form action="ebay/multi_upload_ac.php?ebay_task=<?=$ebay_task;?>" method="post" enctype="multipart/form-data" name="form1" id="form1"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td><strong>Upload Auction Images</strong></td> </tr> <tr> <td>Image 1 <input name="ufile[]" type="file" id="ufile[]" size="50" /></td> </tr> <tr> <td>Image 2 <input name="ufile[]" type="file" id="ufile[]" size="50" /></td> </tr> <tr> <td>Image 3 <input name="ufile[]" type="file" id="ufile[]" size="50" /></td> </tr> <tr> <td align="center"><input type="submit" name="Submit" value="Upload" /></td> </tr> </table> </td> </form> </tr> </table> </BODY> </HTML> Second Page: <?php $path1= "$ebay_task".$HTTP_POST_FILES['ufile']['name'][0]; $path2= "$ebay_task".$HTTP_POST_FILES['ufile']['name'][1]; $path3= "$ebay_task".$HTTP_POST_FILES['ufile']['name'][2]; copy($HTTP_POST_FILES['ufile']['tmp_name'][0], $path1); copy($HTTP_POST_FILES['ufile']['tmp_name'][1], $path2); copy($HTTP_POST_FILES['ufile']['tmp_name'][2], $path3); echo "File Name :".$HTTP_POST_FILES['ufile']['name'][0]."<BR/>"; echo "File Size :".$HTTP_POST_FILES['ufile']['size'][0]."<BR/>"; echo "File Type :".$HTTP_POST_FILES['ufile']['type'][0]."<BR/>"; echo "<img src=\"$path1\" width=\"150\" height=\"150\">"; echo "<P>"; echo "File Name :".$HTTP_POST_FILES['ufile']['name'][1]."<BR/>"; echo "File Size :".$HTTP_POST_FILES['ufile']['size'][1]."<BR/>"; echo "File Type :".$HTTP_POST_FILES['ufile']['type'][1]."<BR/>"; echo "<img src=\"$path2\" width=\"150\" height=\"150\">"; echo "<P>"; echo "File Name :".$HTTP_POST_FILES['ufile']['name'][2]."<BR/>"; echo "File Size :".$HTTP_POST_FILES['ufile']['size'][2]."<BR/>"; echo "File Type :".$HTTP_POST_FILES['ufile']['type'][2]."<BR/>"; echo "<img src=\"$path3\" width=\"150\" height=\"150\">"; /////////////////////////////////////////////////////// // Use this code to display the error or success. $filesize1=$HTTP_POST_FILES['ufile']['size'][0]; $filesize2=$HTTP_POST_FILES['ufile']['size'][1]; $filesize3=$HTTP_POST_FILES['ufile']['size'][2]; if($filesize1 && $filesize2 && $filesize3 != 0) { echo "Images Uploaded Successfully"; } else { echo "ERROR....."; } ////////////////////////////////////////////// // What files that have a problem? (if found) if($filesize1==0) { echo "There're something error in your first file"; echo "<BR />"; } if($filesize2==0) { echo "There're something error in your second file"; echo "<BR />"; } if($filesize3==0) { echo "There're something error in your third file"; echo "<BR />"; } ?> Link to comment https://forums.phpfreaks.com/topic/100481-solved-php-file-upload-going-into-wrong-directory/ Share on other sites More sharing options...
jaxdevil Posted April 10, 2008 Author Share Posted April 10, 2008 WOOPS! I wasn't putting the trailing slash behind the $ebay_task, so it was just appending the $ebay_task variable to the filenames start. My bad Link to comment https://forums.phpfreaks.com/topic/100481-solved-php-file-upload-going-into-wrong-directory/#findComment-513835 Share on other sites More sharing options...
eRott Posted April 10, 2008 Share Posted April 10, 2008 Please be sure to click the "Topic Solved" button at the bottom left of the page. It helps to keep the forum organized. Glad you solved your problem. Take care. Link to comment https://forums.phpfreaks.com/topic/100481-solved-php-file-upload-going-into-wrong-directory/#findComment-513837 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.