Jump to content

How to get a real filename from a variable


simora

Recommended Posts

I am trying to get the actual filename so that I can attach it to an email. 

I tried echo $file;  but its not giving me anything.  Just a blank page.  Here's the code that I' working with:

$file = date('M-d-Y  H:i A'). '.png';
$uri =  substr($data,strpos($data,",")+1);
file_put_contents('./Collection_Posts/'.$file, base64_decode($uri));
echo $file;

exit;

 

 

Link to comment
Share on other sites

Hi requinix:  That's what I thought also,  but I've tried:

 $filename = ('./Collection_Posts/'.$file, base64_decode($uri));

Also  $filename = file_put_contents('./Collection_Posts/'.$file, base64_decode($uri));        Also   $filename = ./Collection_Posts/$file;                                                                                   Trying to echo the filename, I'm not getting anything. 

Link to comment
Share on other sites

2 hours ago, simora said:

Hi requinix:  That's what I thought also,  but I've tried:

$filename = ('./Collection_Posts/'.$file, base64_decode($uri));

That is not valid PHP syntax. Besides, the base-64 stuff is for file_put_contents.

 

Quote

Also  $filename = file_put_contents('./Collection_Posts/'.$file, base64_decode($uri));

According to the documentation, file_put_contents returns "the number of bytes that were written to the file". That does not help you.

 

Quote

Also   $filename = ./Collection_Posts/$file;

Close, except you're not using valid PHP syntax here either.

 

Programming is not a matter of throwing stuff into your IDE until it works. You have to actually understand what things mean and how to use them. Copying and pasting stuff might eventually get you the right answer but it's going to be a pain in the butt until you get there.

Link to comment
Share on other sites

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.