Jump to content

Recommended Posts

Posted

quando tenho o ficheiro upload.php para pasta index funciona bem, mas quando mudo para uma pasta deixa de funcionar e da o seguinte erro

123.pdf

( ! ) Warning: move_uploaded_file(files/123.pdf) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\wamp\www\security\upload.php on line 20

Call Stack

# Time Memory Function Location

1 0.0035 686848 {main}( ) ..\upload.php:0

2 0.0037 688128 move_uploaded_file ( ) ..\upload.php:20

( ! ) Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\wamp\tmp\php934.tmp' to 'files/123.pdf' in C:\wamp\www\security\upload.php on line 20

Call Stack

# Time Memory Function Location

1 0.0035 686848 {main}( ) ..\upload.php:0

2 0.0037 688128 move_uploaded_file ( ) ..\upload.php:20

Erro ao enviar ficheiro.

<?php 
$blacklist = array(".php", ".phtml", ".php3", ".php4");


if(isset($_REQUEST['sub'])) 
{

foreach ($blacklist as $item) {
   if(preg_match("/$item\$/i", $_FILES['uploaded']['name'])) {
       echo "Nao e permitido upload de ficheiros PHP!\n";
       exit;
   }
}

$target = "files/"; 
echo basename($_FILES['uploaded']['name']); 
$target = $target . basename( $_FILES['uploaded']['name']) ; 


if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) 
{ 
echo "O ficheiro:". basename( $_FILES['uploaded']['name']). "\t foi enviado com sucesso"; 
} 
else 
{ 
echo "Erro ao enviar ficheiro."; 
} 
} 

else 
{ ?> <html> 
<body> 
<form enctype="multipart/form-data" action="upload.php" method="POST"> 
Escolha o ficheiro para upload (Maximo 1GB) (Maximo Tempo:12H): <input name="uploaded" type="file" /><br /> 
<input type="submit" value="Upload" name="sub" /> 
</form> 
</body> 
</html><?php 
}?> 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. 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.