Uploading?<

liunx

Guest
Can anyone tell me whats wrong with this script? Heres the webpage:
<!-- m --><a class="postlink" href="http://24.211.125.182/uploader/">http://24.211.125.182/uploader/</a><!-- m -->

And heres the error message i get when i upload something. You can uplaod something, but it wont work:
Warning: move_uploaded_file(CC:\Program Files\Abyss Web Server\htdocs\Download /uploader/filesavg_2.jpg): failed to open stream: Invalid argument in C:\Abyss\htdocs\uploader\upload-teste.php on line 9

Warning: move_uploaded_file(): Unable to move 'C:\PHP\uploadtemp\php49.tmp' to 'CC:\Program Files\Abyss Web Server\htdocs\Download /uploader/filesavg_2.jpg' in C:\Abyss\htdocs\uploader\upload-teste.php on line 9

Thanks,
cokacola650since you only provide the result page and not the php code itself, i can only gess that your destination is wrong
"CC:\Program Files\..."
remove the extra "C"now i get this error: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Abyss\htdocs\uploader\upload-teste.php on line 7 Heres what my code looks like: <?
$path = "C:\Abyss Web Server\htdocs";
/*If you don't know the path just make a small test
create a php file with just <?echo "teste;?> and see the path of the error so copy and paste here :) */
$where_to_go = $path."\uploader\";

while (list ($chave, $valor) = each ($_FILES['file']['tmp_name'])) {

if (move_uploaded_file($_FILES['file']['tmp_name'][$chave], $where_to_go . $_FILES['file']['name'][$chave])) {
print "This upload was successful. Thank You.\n<br>";
} else {
print "\n";
}

}
?>

Thanks,
cokacola650these lines

$path = "C:\Abyss Web Server\htdocs";
$where_to_go = $path."\uploader\";

needs to be

$path = "/Abyss Web Server/htdocs";
$where_to_go = $path."/uploader/";u no, if it wasnt against my religion, i would priase u. thanks for much for helping with this. now i have (hopefully) one more question. Whats my absolute path. I no it must not be C:\Abyss\...... or is it? Everything i plug that in (its another script) i get that T_STRING error message.


edit- if i wanted to get it to create a new directory for every upload using the file name, what code would i add and where?

thanks,
cokacola650you can get the absolute path by doing this

echo $_SERVER['DOCUMENT_ROOT'];

but if you want to get a new folder for every new upload by using the name then do this




<?
$path = "C:\Abyss Web Server\htdocs";

while (list ($chave, $valor) = each ($_FILES['file']['tmp_name'])) {
$where_to_go = $path."\uploader\".$_FILES['file']['name'][$chave]."\";
if (move_uploaded_file($_FILES['file']['tmp_name'][$chave], $where_to_go . $_FILES['file']['name'][$chave])) {
print "This upload was successful. Thank You.\n<br>";
} else {
print "\n";
}

}
?>

that should work but I have no idea why you are using a while loop and I don't know what $chave is.this isnt my script. its a german uploader script i found off i think hotscripts.com. Anyway, i get this erroe message when i use your code: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Abyss\htdocs\uploader\upload-teste2.php on line 6

CODE: <?
$path = "/Abyss/htdocs";

while (list ($chave, $valor) = each ($_FILES['file']['tmp_name'])) {
$where_to_go = $path."'/uploader/".$_FILES['file']['name'][$chave]."\";
if (move_uploaded_file($_FILES['file']['tmp_name'][$chave], $where_to_go . $_FILES['file']['name'][$chave])) {
print "This upload was successful. Thank You.\n<br>";
} else {
print "\n";
}

}
?>

Thanks for the help,
cokacola650wasn't because of me, you have an extra ' in there

$where_to_go = $path."'/uploader/".$_FILES['file']['name'][$chave]."\";oops. dont no how that stuck in there but o well. i too that out but no i get this same error to start with.
Warning: move_uploaded_file(/Abyss Web Server/htdocs/uploader/avg_2.jpg/avg_2.jpg): failed to open stream: No such file or directory in C:\Abyss\htdocs\uploader\upload-teste2.php on line 6 It looks like its looking for the folder, not creating a new one??

thanks,
cokacola650ahh, you have to create it first, sorry.

<?
$path = "/Abyss/htdocs";

while (list ($chave, $valor) = each ($_FILES['file']['tmp_name'])) {
mkdir($path."/uploader/".$_FILES['file']['name'][$chave], 0777);
$where_to_go = $path."/uploader/".$_FILES['file']['name'][$chave]."\";
if (move_uploaded_file($_FILES['file']['tmp_name'][$chave], $where_to_go . $_FILES['file']['name'][$chave])) {
print "This upload was successful. Thank You.\n<br>";
} else {
print "\n";
}

}
?>theres no way for me to have it set up so that whenever a user uploads a file (for example called planes.zip) and then create a folder for each and every file that is uploaded?

cokacola650that is what this will do

mkdir($path."/uploader/".$_FILES['file']['name'][$chave], 0777);ahh right, missed that looking over it the first time. thanks for the help.

cokacola650
 
Back
Top