Jump to content

Recommended Posts

I recently submitted a plugin to WordPress and they told me to sanitize my file name here is the examples they gave me. 

 

Quote

basename is great, but you also want to sanitize the filenames

image-framer/image-framer.php:135: $targetFile = $targetPath . '/imageframer/' . basename($_FILES['image']['name'][$i]);
image-framer/image-framer.php:138: $returnResponse[$i] = $dir['baseurl'] . '/imageframer/' . $_FILES['image']['name'][$i];
image-framer/image-framer.php:162: $targetFile = $targetPath . '/imageframer/' . basename($_FILES['uploadimg']['name']);
image-framer/image-framer.php:165: $returnResponse = $dir['baseurl'] . '/imageframer/' . $_FILES['uploadimg']['name'];
image-framer/src/Validation.php:13: $imageFileType = strtolower(pathinfo($targetPath . '/imageframer/' . basename($_FILES['image']['name'][$index]), PATHINFO_EXTENSION));

How would I go about sanitizing file names? Thanks all for your help.

Link to comment
https://forums.phpfreaks.com/topic/314265-sanitize-file-names-wordpress/
Share on other sites

  • 5 months later...
On 12/3/2021 at 9:37 AM, Phpman88 said:

I recently submitted a plugin to WordPress and they told me to sanitize my file name here is the examples they gave me. 

 

image-framer/image-framer.php:135: $targetFile = $targetPath . '/imageframer/' . basename($_FILES['image']['name'][$i]);
image-framer/image-framer.php:138: $returnResponse[$i] = $dir['baseurl'] . '/imageframer/' . $_FILES['image']['name'][$i];
image-framer/image-framer.php:162: $targetFile = $targetPath . '/imageframer/' . basename($_FILES['uploadimg']['name']);
image-framer/image-framer.php:165: $returnResponse = $dir['baseurl'] . '/imageframer/' . $_FILES['uploadimg']['name'];
image-framer/src/Validation.php:13: $imageFileType = strtolower(pathinfo($targetPath . '/imageframer/' . basename($_FILES['image']['name'][$index]), PATHINFO_EXTENSION));

How would I go about sanitizing file names? Thanks all for your help.

A year ago, I was also searching for its answer, but today I know.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.