dguimaraes Posted February 1, 2016 at 12:54 PM Report Share #592868 Posted February 1, 2016 at 12:54 PM Boas, Arranjei um sample de upload de ficheiros e está a funcionar, mas queria alterar o nome em o que ficheiro e guardado para um nome fixo por mim mas continuo por exemplo hj faco upload de um ficheiro ele faz imagem1, se fizer logo de seguida ele guardar imagem2.... <?php $arquivo = $_FILES['arquivo']; if ($arquivo['type'] == "image/jpeg" || $arquivo['type']== "image/pjpeg") { if ($arquivo['size']>500000) { exit('Arquivo muito grande. Tamanho máximo permitido 500kb. O arquivo enviado contém '.round($arquivo['size']/1024).'kb'); } $novonome = md5(mt_rand(1,10000).$arquivo['name']).'.jpg'; $dir = "reports/"; if (!file_exists($dir)) { mkdir($dir, 0755); } $caminho = $dir.$novonome; move_uploaded_file($arquivo['tmp_name'],$caminho); echo '<script type="text/javascript">alert("Arquivo enviado!")</script>'; echo '<meta http-equiv="refresh" content="1; url=index.html" />'; } else{ echo "Arquivo inválido. É permitido somente imagem com extensão .jpg."; } ?> Link to comment Share on other sites More sharing options...
tiago.f Posted February 1, 2016 at 01:29 PM Report Share #592874 Posted February 1, 2016 at 01:29 PM A tua variavel $novonome define o nome do ficheiro. Apenas tens que garatir que tem o valor/string que tu queres. (e não um número aleatório como está agora) Link to comment Share on other sites More sharing options...
dguimaraes Posted February 1, 2016 at 02:08 PM Author Report Share #592877 Posted February 1, 2016 at 02:08 PM A tua variavel $novonome define o nome do ficheiro. Apenas tens que garatir que tem o valor/string que tu queres. (e não um número aleatório como está agora) Thanks void:) Sempre atento Link to comment Share on other sites More sharing options...
tiago.f Posted February 1, 2016 at 02:36 PM Report Share #592878 Posted February 1, 2016 at 02:36 PM (edited) Thanks void:) Sempre atento De nada void! ...algo me diz que o design/ui que este forum usa não é muito bom para identificar o nome das pessoas ... 🙂 Edited February 1, 2016 at 02:37 PM by tiago.f Link to comment Share on other sites More sharing options...
NaDa Posted February 1, 2016 at 03:03 PM Report Share #592880 Posted February 1, 2016 at 03:03 PM Lool xP #somostodosvoid Link to comment Share on other sites More sharing options...
dguimaraes Posted February 2, 2016 at 09:00 AM Author Report Share #592916 Posted February 2, 2016 at 09:00 AM De nada void! ...algo me diz que o design/ui que este forum usa não é muito bom para identificar o nome das pessoas ... 🙂 Thaks Tiago F. Realmente só reparei agora que o nome está em cima hahah 1 Report Link to comment Share on other sites More sharing options...
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