Remove Spaces From Upload

mpw5013 05 Oct, 2011
How do I remove spaces from my uploads? I want to replace them with underscores. This isn't working:

<?php
$file_name = basename($attachments['file_upload']);
$file_name = str_replace(" ","_",$file_name);
?>

I did replace basename too and received an error.

What I'm trying to do is remove the spaces from the upload and then add the new URL to the email.

<tr>
<td>
<strong>Attachment:</strong></td>
<td>
http://localhost/uploads/<?php echo $file_name ?>
</td>
</tr>

Any ideas?
GreyHead 05 Oct, 2011
Hi mpw5013,

I think that you'd need to rename the file as well as edit the file name or the two will no longer be connected.

What is the problem that you are trying to solve? Just to get links into the email? If so, then my File Upload [GH] action might help as it adds a file link into the form data - you can then use {input_name_url} in the Email template - and from memory that is urlencoded so the spaces should be handled OK (if not then I can easily fix it).

Bob
mpw5013 05 Oct, 2011
SOLVED Thanks!
1) Drag the new action over (Upload Files [GH])
2) Use {fieldname}_{fieldname} in the File name box
3) Use http://localhost/{uploadFileFieldName_url} in the email template
4) Example: http://localhost/{attachment_url} you need the _url portion the other part is the filed name that you used in the "Previews Tab" under "Field Name"...

Hope this helps thanks again!
GreyHead 05 Oct, 2011
Hi mpw5013,

Sorry, I wrote some shorthand there. Where 'input_name' appears it needs to be replaced with the actual name of the input - looks like 'resume' in this case. So you'd have {resume_url} in the Email template.

The screen shot looks like the standard Uploads File action - you should also have an Upload Files [GH] action in the Actions tab with slightly longer help and a File Name input.

You probably don't want to include {input_name} in the Uploads path line as this will create a new folder for each upload.

Bob
mpw5013 05 Oct, 2011
Thanks Bob,

I updated my message with instructions and marked it as SOLVED! I really appreciate it!
This topic is locked and no more replies can be posted.