HTML表单不会发送一些POST变量到PHP脚本

HTML表单不会发送一些POST变量到PHP脚本

本文介绍了HTML表单不会发送一些POST变量到PHP脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



每当我正确地填写每一份表格,并且每次填写表格时,提交它,一堆变量没有设置为向上加载器。



HTML表单(从我的网站截取,我只留下了一些引导程序元素case):

 < form action =upload.phpmethod =post> 
< span style =color:green;>选择您要上传的文件:< / span>
< input type =fileclass =form-controlname =fileToUploadid =fileToUpload/>
< br>提示:上传后需要很长时间才能加载页面?这是您的浏览器上传文件。如果您的网络速度较慢或者您正在上传大文件,则需要时间。
< br>< br>
< b>< span style =color:red;>免责声明:我,Mark Jones对上传色情,盗版音乐,图像和电影不负责任。如果上传任何盗版,冒犯性或性文件,他们将被员工删除或通过存储清理删除。请保留所有这些类型的文件不允许远离本网站。只上传不在其他地方销售的东西,并将色情片保存在自己的电脑上。一旦您在接受该免责声明后上传文件(不接受文件而不能上传文件),上传的文件将成为您的责任。它将被删除,如果它没有被删除,那么你将不得不目睹我的惩罚,但我的主机或DMCA等其他人没有实施。我也希望本网站的所有会员/用户不要上传病毒,Tojans,恶意软件和间谍软件。如果你这样做,它将被删除或其他惩罚将发生。 < / span>< / b>< br>< br>< br>您也可以通过接受此免责声明来使用您的真实姓名。
<! - < input type =submitvalue =Upload Imagename =submit/> - >
< input type =radioname =disclaimervalue =1>接受< /输入>
< input type =radioname =disclaimervalue =0checked> Decline< / input>< br>< br>
请在下面输入您的全名:< br>
< input type =textclass =form-controlname =realnamevalue =Full name>< / input>< br>
您是否希望为自己的文件创建个人文件夹?< br>
< input type =radioname =pfvalue =1>是< / input>
< input type =radioname =pfvalue =0checked>否< / input>< br>
< input type =textclass =form-controlname =pfnvalue =个人文件夹名称>< / input>< br>< br>
请标记您的文件:< br>
< input type =radioname =tagvalue =otherchecked>其他< / input>
< input type =radioname =tagvalue =funny> Funny< / input>< br>
< input type =radioname =tagvalue =theoretic> Theoretic< / input>
< input type =radioname =tagvalue =sad> Sad< / input>< br>
< input type =radioname =tagvalue =important>重要< / input>
< input type =radioname =tagvalue =informative>资讯< /输入>< br>
< input type =radioname =tagvalue =family> Family< / input>
< input type =radioname =tagvalue =友善>友善< /输入>< br>
< input type =radioname =tagvalue =dangerous>危险< / input>
< input type =radioname =tagvalue =horrible>可怕< / input>< br>
< input type =radioname =tagvalue =scary> Scary< / input>
< input type =radioname =tagvalue =musical>音乐< /输入>< br>
< input type =radioname =tagvalue =creative> Creative< / input>
< input type =radioname =tagvalue =丑陋>丑< / input>< br>
< / div>
< div class =modal-footer>
< b>如果在任何地方使用,,/或\,上传程序会中断。< / b>
< button type =buttonclass =btn btn-defaultdata-取消请求< / button>
< input type =submitid =uploadsubmitclass =btn btn-primaryvalue =Uploadname =submit> < / input>
< / form>

接下来是我的PHP处理程序(

 < center> 

if (isset($ _ POST [disclaimer])&& isset($ _ POST [realname])){

if($ _ POST [disclaimer]!=1) {
die(您不接受免责声明,返回页面并阅读免责声明。);
}

if($ _ POST [realname] ==全名){
die(您没有输入真实姓名,请返回并重试。);
}

if($ _ POST [realname] ==){
die(您没有输入真实姓名,请返回并重试。);
}

}其他{

回声呃哦!出事了! < br>;
$ _POST [realname] ==real-name-post-error;

}


$ personalfolder = $ _POST [pf];

//基本文件名
$ base_file_name = basename($ _ FILES [fileToUpload] [name]) ;
$ base_file_name_path = $ _FILES [fileToUpload] [name];

if(!empty($ _ SERVER ['HTTP_CLIENT_IP'])){
$ ip = $ _SERVER ['HTTP_CLIENT_IP'];
} elseif(!empty($ _ SERVER ['HTTP_X_FORWARDED_FOR'])){
$ ip = $ _SERVER ['HTTP_X_FORWARDED_FOR'];
} else {
$ ip = $ _SERVER ['REMOTE_ADDR'];
}

//主要脚本
echo上传的文件。读取文件列表...< br>;
if($ personalfolder ==1){
$ target_dir_ext = time()。_。basename($ _ FILES [fileToUpload ] [name])。_。$ ip。$ _ POST [realname]。/。$ _ POST [pfn]; //防止文件已存在
} else {
$ target_dir_ext = time()。_。basename($ _ FILES [fileToUpload] [name])。_。$ ip。$ _ POST [realname]; //防止文件已经存在
}
$ structure =uploads /\".$_ POST [tag]。/。$ target_dir_ext;
mkdir($ structure,0777,true);
$ target_dir =uploads /\".$_ POST [tag]。/。$ target_dir_ext。/;
$ target_file = $ target_dir。basename($ _ FILES [fileToUpload] [name ]);
echo检测到文件:< br>。$ target_file。< br>;
echoChecking file(s)...< br> ;

$ uploadOk = 1;
$ imageFileType = pathinfo($ target_file,PATHINFO_EXTENSION);
//检查文件是否已经存在
if(file_exists($ target_file )){
echoSorry,file already exists。< br>;
$ uploadOk = 0;
}
// Che ck文件大小
if($ _FILES [fileToUpload] [size]> 99999999){
echo对不起,您的文件太大。< br>;
$ uploadOk = 0;
}
//允许某些文件格式
if($ imageFileType!=jpg
&& $ imageFileType!=png
&& amp ; $ imageFileType!=jpeg
&& $ imageFileType!=GIF
&& $ imageFileType!=JPG
&& $ imageFileType!= JPEG
&& $ imageFileType!=PNG
&& $ imageFileType!=mp3
&& $ imageFileType!=MP3
&& $ imageFileType!=WAV
&& $ imageFileType!=wav
&& $ imageFileType!=mp4
&& amp ; $ imageFileType!=MP4
&& $ imageFileType!=swf
&& $ imageFileType!=SWF
&& $ imageFileType!= ogg
&& $ imageFileType!=OGG
&& $ imageFileType!=js
&& $ imageFileType!=JS
&& $ imageFileType!=txt
&& $ imageFileType!=TXT
&& $ imageFileType!=exe
&& amp ; $ imageFileType!=EXE
&& $ imageFileType!=zip
&安培;&安培; $ imageFileType!=ZIP
&& $ imageFileType!=rar
&& $ imageFileType!=RAR
&& $ imageFileType!=msi
&& $ imageFileType!=MSI
&& $ imageFileType!=ttf
&& $ imageFileType!=TTF
&& $ imageFileType!=svg
&& $ imageFileType!=SVG
&& $ imageFileType!=eot
&& $ imageFileType!=EOT
&& $ imageFileType!=woff
&& $ imageFileType!=WOFF
&& $ imageFileType!=woff2
&& $ imageFileType!=WOFF2
&& $ imageFileType!=gif){
echo对不起,只允许使用JPG,JPEG,PNG,GIF,OGG,MP3,MP4,WAV和SWF文件。
$ uploadOk = 0;
}
//如果$ uploadOk == 0 {
echo抱歉,您的文件没有被上传,因为错误
检查$ uploadOk是否被设置为0上述原因。< br>;
//如果一切正常,请尝试上传文件
} else {
echo文件正常。尝试将上传的文件移至上传目录... ;
if(move_uploaded_file($ _ FILES [fileToUpload] [tmp_name],$ target_file)){
echoThe file。 basename($ _FILES [fileToUpload] [name])。 已上传。< br>;
$ ul =http://marksrtz.site50.net/uploader/\".$target_file;
echoFile URL:< a href ='。$ ul。'>。$ ul。< / a>< br>;
if($ imageFileType ==jpg
|| $ imageFileType ==png
|| $ imageFileType ==PNG
|| $ imageFileType == gif
|| $ imageFileType ==GIF
|| $ imageFileType ==jpeg
|| $ imageFileType ==JPEG
|| $ imageFileType = =JPG){
echo'Preview:< br>< iframe width =1440pxheight =900pxsrc ='。$ ul。'>< / iframe> ;
} else {
echo'Preview:< br>< iframe width =600pxheight =400pxsrc ='。$ ul。'>< / iframe> ;
}
} else {
echo抱歉,上传文件时发生错误。;
}
}
echo< br> PHP Script被执行并正确结束。
?>
< / center>

问题是什么? PHP脚本的输出是:

What it wasn't detecting earlier was the $_POST["disclaimer"] and $_POST["realname"] but then that started working a little later

Now it isn't sending the file I want to upload at all.

However, If i use an enctype it does send the file but it won't send the POST variables. Is there a way i can send the POST Variables and the file at the same time without creating another form?

解决方案

I'm just going to go ahead and make this an answer.

000webhost most likely have a default 2M upload max.

You can override that using .htaccess and changing its value to

php_value memory_limit 30M
php_value post_max_size 100M
php_value upload_max_filesize 30M

for example and placed in the root of your server. Since you are unable to modify their php.ini file.

As per a few findings done on Google for you.

http://www.000webhost.com/forum/customer-assistance/202-file-upload-limit-2mb-set-php-ini.html

as it's stated We do not allow to upload big files (where file size is more than 5 MB) on serverIn a backend of my component (Pictures Gallery) there is a statement that Upload file limit is 2Mb - set by php.iniI use Joomla. Does anybody know how to increase it up to 5Mb?Is it on server or somewhere in my file system?

and

the limit on this hosting for uploading files is 2Mb, you can check in phpinfo().

Plus, just for argument's sake:

Form requires a valid enctype when uploading; you don't have one.

Change your form to this:

<form action="upload.php" method="post" enctype="multipart/form-data">

这篇关于HTML表单不会发送一些POST变量到PHP脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 20:28