nineninefour Posted June 27, 2006 Share Posted June 27, 2006 Hello!Well, I've done my best. I've googled, ask.comed, read the documentation and searched the forums.I'm trying to move uploaded files to an already created directory:Here's the (abbreviated) form. I'm aware there is no doctype or anything. I'm just trying to get the php to work first:[code]<html><body><form name="upload" enctype="multipart/form-data" action="uploadtest.php" method="post">Item Name: <p>Upload Your Pictures!<input type="file" name="userfile[]" /><input type="file" name="userfile[]" /><input type="file" name="userfile[]" /><input type="file" name="userfile[]" /><input type="file" name="userfile[]" /></p><br /><input type="submit" value="Add New item!" /></form> </body></html>[/code]And here is the php:[code]<?php$dbh=mysql_connect ("localhost", "XXXXXXXXX", "XXXXXXX") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("ninenine_xxxxxxxxx");$num = rand(0, 99999);$umask = umask(0);$default = "default.html";$dest = "items/$num/default.html";$uploaddir = "items/$num/images/";$uploadfile = $uploaddir . basename($_FILES['userfile']['name'][$key]);mkdir("items/$num", 0777); //gets created no probmkdir("$uploaddir", 0777); //also works greatumask($umask);copy($default, $dest); //copies my default file into the new directory, works greatforeach($_FILES['userfile']['name'] as $key => $value) { move_uploaded_file($_FILES['userfile']['tmp_name'][$key], $uploadfile); //THIS IS LINE 27 }?>[/code]Here is the error i get:[code]Warning: move_uploaded_file(items/32142/images/): failed to open stream: Is a directory in /home/ninenine/public_html/vegasitems/uploadtest.php on line 27Warning: move_uploaded_file(): Unable to move '/tmp/phppnPllB' to 'items/32142/images/' in /home/ninenine/public_html/vegasitems/uploadtest.php on line 27Warning: move_uploaded_file(items/32142/images/): failed to open stream: Is a directory in /home/ninenine/public_html/vegasitems/uploadtest.php on line 27Warning: move_uploaded_file(): Unable to move '/tmp/phpWjD0Ml' to 'items/32142/images/' in /home/ninenine/public_html/vegasitems/uploadtest.php on line 27[/code] Quote Link to comment Share on other sites More sharing options...
nineninefour Posted June 28, 2006 Author Share Posted June 28, 2006 Bump [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /] Quote Link to comment Share on other sites More sharing options...
adamwhiles Posted June 28, 2006 Share Posted June 28, 2006 try changing this line:[code]move_uploaded_file($_FILES['userfile']['tmp_name'][$key], $uploadfile);[/code]to this:[code]$file = $_FILES["userfile"]["tmp_name"][$key];move_uploaded_file($file, "items/$num/images/$uploadfile");[/code] Quote Link to comment Share on other sites More sharing options...
nineninefour Posted June 28, 2006 Author Share Posted June 28, 2006 Awesome! Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.