jonypedrosa Posted April 21, 2012 at 02:08 AM Report #450357 Posted April 21, 2012 at 02:08 AM 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 }?>
HappyHippyHippo Posted April 21, 2012 at 02:14 AM Report #450359 Posted April 21, 2012 at 02:14 AM que caminho é este ??? files/123.pdf pensa um bocadito que vais lá chegar ... o problema está no caminho dado IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
jonypedrosa Posted April 21, 2012 at 08:37 AM Author Report #450365 Posted April 21, 2012 at 08:37 AM Mudei para $target = "../files/"; e ja funciona, obrigado 😛
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now