Hi. I have an image upload program. It's very simple. Currently, it just uploads an image to one directory. The directory must be present, or the file will not upload.
What I would like is some code to check to see if the directory already exists. If it exists, it should simply just upload to the directory.
However, if the directory does not exist, it will mkdir, then chmod 777, then continue to upload the image.
I've tried just about everything, of course I'm not a php pro like many of you guys. I've been helped out here before, and I know you guys will be able to help again.
Thank you in advance. I'll keep any eye on this thread.
Bryan
Here is the code for the actual upload form file. This just selects the image from your HD, and sends that data to the upload.php file code (bottom).
<FORM ACTION="/upload.php" METHOD="POST" ENCTYPE="multipart/form-data">
<INPUT TYPE="file" NAME="img1" SIZE="30"><p><INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Upload">
</FORM>
Here is the code for the upload.php file. This does the actual work of uploading the file. Here is where I need the php to check to see if the directory "/home/securep/public_html/SSL/temp" already exists. If it doesn't, create it, and then upload the image.
<?php
if ($img1_name != "") {
@copy("$img1" , "/home/securep/public_html/SSL/temp/$img1_name")
or die("Error! File not uploaded.");
} else {
die("Error! No file specified.");
}
?>