Rumah > pembangunan bahagian belakang > tutorial php > php上传文件代码 php文件上传代码 php curl 上传文件 php 多文件上

php上传文件代码 php文件上传代码 php curl 上传文件 php 多文件上

WBOY
Lepaskan: 2016-07-29 08:54:06
asal
1044 orang telah melayarinya

<code><span><span>html</span>></span><span>head</span>><span>meta</span><span>charset</span>=<span>"utf8"</span>><span>title</span>>upload<span><span>title</span>></span><span><span>head</span>></span><span>body</span>><span>form</span><span>action</span>=<span>"upload_file.php"</span><span>method</span>=<span>"post"</span><span>enctype</span>=<span>"multipart/form-data"</span>><span>label</span><span>for</span>=<span>"file"</span>>Filename:<span><span>label</span>></span><span>input</span><span>type</span>=<span>"file"</span><span>name</span>=<span>"file"</span><span>id</span>=<span>"file"</span> /><span>br</span> /><span>input</span><span>type</span>=<span>"submit"</span><span>name</span>=<span>"submit"</span><span>value</span>=<span>"submit"</span> /><span>br</span> /><span><span>form</span>></span><span><span>body</span>></span><span><span>html</span>></span></code>
Salin selepas log masuk
<code><span><span><?php </span><span>if</span>((<span>$_FILES</span>[<span>'file'</span>][<span>'type'</span>] == <span>"image/gif"</span>)||
  (<span>$_FILES</span>[<span>'file'</span>][<span>'type'</span>] == <span>"image/jpeg"</span>)||
  (<span>$_FILES</span>[<span>'file'</span>][<span>'type'</span>] == <span>"image/pjpeg"</span>)&&
  (<span>$_FILES</span>[<span>'file'</span>][<span>'size'</span>] 20000</span>))
  {
     <span>if</span> (<span>$_FILES</span>[<span>"file"</span>][<span>"error"</span>] > <span>0</span>)
     {
        <span>echo</span><span>"Error: "</span> . <span>$_FILES</span>[<span>"file"</span>][<span>"error"</span>] . <span>"<br>"</span>;
     }
     <span>else</span>
     {
        <span>echo</span><span>""</span>;
        <span>echo</span><span>""</span>;
        <span>echo</span><span>"<meta charset="utf8">"</span>;
        <span>echo</span><span>"Upload: "</span> . <span>$_FILES</span>[<span>"file"</span>][<span>"name"</span>] . <span>"<br>"</span>;
        <span>echo</span><span>"Type: "</span> . <span>$_FILES</span>[<span>"file"</span>][<span>"type"</span>] . <span>"<br>"</span>;
        <span>echo</span><span>"Size: "</span> . (<span>$_FILES</span>[<span>"file"</span>][<span>"size"</span>] / <span>1024</span>) . <span>" Kb<br>"</span>;
        <span>echo</span><span>"Stored in: "</span> . <span>$_FILES</span>[<span>"file"</span>][<span>"tmp_name"</span>];
        <span>echo</span><span>""</span>;
        <span>echo</span><span>""</span>;
        <span>if</span>(file_exists(<span>"upload/"</span> . <span>$_FILES</span>[<span>'file'</span>][<span>'name'</span>]))
        {
            <span>echo</span><span>$_FILES</span>[<span>'file'</span>][<span>'name'</span>].<span>"already exists. "</span>;
        }
        <span>else</span>
        {
             move_uploaded_file(<span>$_FILES</span>[<span>"file"</span>][<span>"tmp_name"</span>],
             <span>"/usr/local/nginx/html/upload/"</span> . <span>$_FILES</span>[<span>"file"</span>][<span>"name"</span>]);
             <span>echo</span><span>"Stored in: "</span> . <span>"/usr/local/nginx/html/upload/"</span> . <span>$_FILES</span>[<span>"file"</span>][<span>"name"</span>];
        }
     }
  }
  <span>else</span>
  {
     <span>echo</span><span>"Invaild file"</span>;
  }
<span>?></span></span></code>
Salin selepas log masuk
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

以上就介绍了php上传文件代码,包括了上传文件,php方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan