简体   繁体   English

取消链接失败,文件名中包含空格

[英]unlink fails with space in filename

I am trying to unlink files which have their checkbox ticked, but I am getting this error with filenames having spaces like "Untitled Document" (it reads up to 'Untitled'): 我正在尝试取消链接选中了其复选框的文件,但是却出现文件名带有“ Untitled Document”之类的空格的错误(读取为“ Untitled”):

Warning: unlink(../pdf_files/Untitled) [function.unlink]: No such file
or directory in C:\xampp\htdocs

I am passing the values using: 我正在使用传递值:

<input type="checkbox" name="file[]" value = ' . $num . ' />';

It appears that the array file[] stores the first word of a filename containing spaces. 似乎数组file[]存储包含空格的文件名的第一个单词。 How can I fix this please? 我该如何解决?

You need to wrap the value attribute in quotes. 您需要将value属性包装在引号中。 Otherwise it will show like this: 否则它将显示如下:

<input type="checkbox" name="file[]" value=Untitled Document />

So the browser will only see Untitled as the value and then have a stray Document attribute which does nothing. 因此,浏览器将仅将Untitled作为value ,然后具有一个杂散Document属性,该属性不执行任何操作。 Try the following: 请尝试以下操作:

echo '<input type="checkbox" name="file[]" value="' . $num . '" />';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM