0

I've been issued with the task of when an e-mail is sent to a specific e-mail address it should upload it to a folder called 'input' I have to check this folder for changes to see if there are any .PDF files in so I can allow them through to be converted to a .DOC file and be stored in another folder called 'output' and then send it back to the user that e-mailed it, where would I start with this?!

2 Answers 2

3

You could store the md5 of the folder content in some place (database, file, cookies..) and then if the folder contents change, the md5 will also change.

More about md5.

You can find a function for it here.

Sign up to request clarification or add additional context in comments.

3 Comments

This seems like a good answer, but how would I do it so that when the user e-mails the file it renames the file dependent on the e-mail it is sent from? I assume I have to do something with POP but I'm not sure what? The last part of e-mailing it back is fine, I'm connected through the SMTP server and using something called mailer to send it back it's just becoming a bit of a pain
That's another different question. Open a new one for it.
0

you can do something like:

<?php $filename = '/path/to/input_folder/yourfile.pdf'; if (file_exists($filename)) { //do convert to .doc } else { //do something else } ?> 

just explore file-related php funcion

4 Comments

Thanks I will make use of this would this work <?php $allowedExtensions = array ("pdf"); $filename = '/path/to/input_folder/yourfile.pdf'; if (file_exists($filename && $allowedExtensions)) { //do convert to .doc } else { //do something else } ?>
do you want to check the file extension first?
Yes it HAS to be of .pdf format to be able to go through if it's not then delete it and send the user an e-mail saying "error blah blah blah"
if so, you have to (and it is recommended due to security) check-it before you upload it into 'input' folder.