PHP - Pictures Say They Are Uploaded But They Do Not Show
I am working on this pictures to upload and when I submit it gives the message below for success but I get this error message which is on the line of $place file
Warning: move_uploaded_file(members/5/image01.jpg) [function.move-uploaded-file]: failed to open stream: $check_pic = "members/$id/image01.jpg"; $default_pic = "members/0/image01.jpg"; $newname = "image01.jpg"; $place_file = move_uploaded_file( $_FILES['fileField']['tmp_name'], "members/$id/".$newname); $success_msg = '<font color="#009900">Your image has been updated, it may take a few minutes for the changes to show... please be patient.</font>'; Similar TutorialsHi there, Can you guys/girls tell me if this is even possible: - take pictures with eye-fi card in the camera, which uploads the images to a server - on the server, automatically add a watermark, and post them on 3 different facebookpages try { echo "<br>"; foreach($dbh->query("SELECT * FROM test_shot WHERE sold=1 ORDER BY year ASC") as $row) { if($row['picture'] != "" && $row['picture'] != null) { echo "<div class='image-holder'><img src ='".$row['picture']."' width=300px /><br>"; } if($row['year'] != "" && $row['year'] != null) { echo $row['year']; } if($row['description'] != "" && $row['description'] != null) { echo $row['description']; } if($row['sold'] == 1) { echo "<img src='images/sold1.png'><br>";//Add your image code here } elseif ($row['sold'] == 0) { echo "</div><br>"; } } } catch (PDOException $e) { print $e->getMessage(); } ?>
hi everyone i am currently making my website with an uploadform. The upload function is working, but now i am trying to make the site remember the last 5 uploads. The filenames should appear in an array: $aotf[0] $aotf[1] $aotf[2] $aotf[3] $aotf[4] and since all files that can be/are uploaded are images, i want them to be drawed next to each other, each 128x128. THAT is working, but the fetch for images doesn't. When an image is uploaded, i execute this code: $readhandle=fopen("uploaddb.log","r"); $aotf=fread($handle,filesize("uploaddb.log")); fclose($readhandle); $writehandle=fopen("uploaddb.log","w"); fwrite($writehandle,"$aotf\r\n" . "uploadform/gebruikers/" . $naam); fclose($writehandle); then,there is some html code, and then there is this code: $aotf=explode("/n",$aotf); for($i = count($aotf) - 5; $i <= count($aotf); $i++) { echo ' <img src="'. $aotf[$i] . '" width="128" height="128"> '; } when i open the page, all img src's are empty. The writing works, and the folder of the image is 7777 chmod and the images draw on the screen, but not as the last uploaded. Does anyone know how to make this work? maybe even without a fwrite? Thank you, masterens EDIT: i cannot use mysql I am looking for help on guiding me to a way for a user to upload a group of pictures for a slide show. can some one help? I have a news page that a user is able to upload new stories or edit and upload one photo, but now i want that user to upload a group of pictures for a slideshow. hope all this makes sense. show list of files uploaded by current session user to the database. I want to show different users when they log in to the website...they can see a list of old files that they have uploaded. can anyone tell me the code/script to this.....please, ty Hello, I have a form for uploading CV files into a CV database. Once the files are uploaded to their directory (e.g. www.jobsboard.com/cvdatabase/) please could someone tell me how to restrict access to users? e.g. once a user logs into their userpanel they should be able to click on a hyperlink to download a CV e.g. (www.jobsboard.com/cvdatabase/CV1.doc) but a user who isn't logged in shouldn't be able to access www.jobsboard.com/cvdatabase/CV1.doc Please could you tell me whether this is possible? Many thanks, Stu At the moment I have been uploading files to my server using <input type='files'> and binary encrytion. I would like to have more controll over the files tmp_name. is there a way to assing it befor hand? if you have the urls to pictures in a database how would you display the actual pictures on a webpage? Here 's the code. Code: [Select] <?php require_once("functions.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> td { border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #30C; border-right-color: #30C; border-bottom-color: #30C; border-left-color: #30C; } </style> </head> <body> <?php navBar(); echo "<form action=\"\" method=\"post\" name=\"catalog\">"; DatabaseConnection(); $query = "SELECT * FROM treats"; $result_set = mysql_query($query) or die(mysql_error()); $i = 0; echo "<table>"; while ($row = mysql_fetch_array($result_set)) { echo"<tr><td width=\"400px\">($row['product_pic']). <br />{$row['product_id']}.<br />{$row['product_title']}.<br /> {$row['product_Description']}.<br />{$row['product_price']}</td></tr>"; } echo "</table>"; ?> </form> </body> </html> Hello, like I promised, I'm back with another problem. This one will be harder xD so squeeze your brain
Now I've got a webpage, with a database shown into a table, under that I've got page numbers. So I got my 20 rows for each page.
https://www.dropbox..../stillnotok.jpg
Great/awesome so far
Now I've got a new problem and it's hard for me to explain this too.
In my database I got allot of tables, in my webpage I'm using 2 of them, called 'artikel' and 'images".
Everything from my artikel table is ok. So we don't need to look at that.
But my problem is with the table 'images'.
In that table I got 2 items.
Like you will see in my code, I need the I_ARTCODE and I_FILE
in I_ARTCODE stands: 14 and for the other image 15
in I_FILE stands: 5.jpg and for the other image 6.jpg
With the code I've got now, I display the word 5.jpg and 6.jpg.
But I need to display the picture behind that, the person who gave me this task sayed, I normally can do this with the pad but it's not a real url, I'll give you guys a picture how my database looks like:
https://www.dropbox....uqplxd/path.jpg
Over here the pad is this: 000000-001000
It doesn't seems normal to me and I can't find a sollution for this on the internet.
Can someone plz help me?
Ooh ya, almost forgot, this is my code:
<?php include('connect-mysql.php'); if (!empty($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; }; $start_from = ($page-1) * 20; $sqlget = "SELECT * FROM artikel, images LIMIT $start_from, 20 "; $sqldata = mysqli_query($dbcon, $sqlget) or die('error getting'); echo "<table>"; echo "<tr><th>A_ARTCODE</th><th>A_NUMMER</th><th>A_OMSCHRN</th><th>A_REFLEV</th><th>A_WINKEL</th><th>I_ARTCODE</th><th>I_FILE</th></tr>"; while($row = mysqli_fetch_array($sqldata)){ echo "<tr><td align='right'>"; echo $row['A_ARTCODE']; echo "</td><td align='left'>"; echo $row['A_NUMMER']; echo "</td><td align='left'>"; echo $row['A_OMSCHRN']; echo "</td><td align='left'>"; echo $row['A_REFLEV']; echo "</td><td align='right'>"; echo $row['A_WINKEL']; echo "</td><td align='right'>"; echo $row['I_ARTCODE']; echo "</td><td align='right'>"; echo $row['I_FILE']; //echo "<img src='000000-001000".$row['I_ID']."' />"; echo "</td></tr>"; } echo "</table>"; $sql = "SELECT COUNT(A_ARTCODE) FROM artikel"; $rs_result = mysqli_query($dbcon, $sql) or die ("mysqli query dies"); $row = mysqli_fetch_row($rs_result) or die ("mysqli fetch row dies"); $total_records = $row[0]; $total_pages = ceil($total_records / 20); for ($i=1; $i<=$total_pages; $i++) { echo "<a href='index.php?page=".$i."'>".$i."</a> "; }; ?> Hi, i would like to know what is the best method to store a picture. Currently what happens, is each user has a different avatar, which when uploaded comes in a folder called Avatar, in my website folder and is also stored as a BLOB in mysql. I would like to know is this ok to store all avatars in one folder or some other step should be used and if so could some one guide me to a good tutorial. As I would also like to make an option, where people could upload their pictures, is it safe to store pictures in the same folder for all users or some how create a different folder for each user. Hi,
I have a crwal engine and every time when I try to take a picture from a specific website, it also take some bullshit from superfish, creating iframe and div class, that I can`t deleted using jquery after my page is load.
I was looking in my code and I found out that the only thing that trigger that is the <img src="<?php h(getPicture($itemRow['site'], if I remove 'site', I don`t see any other superfish code but also don`t see the picture. What can I do to take only the .jpg picture , without any of the other crap?
<?php for ($i = 0; $i < count($itemRow['pics']); $i++) { ?> My 1st try practice uploading file to the server and it was successful. Now I wonder how can I set a default file name to the file that will be uploaded and overwrite the existing one. I have tried experimenting on the code but I can't get it to work. Here's my simple code.. edit_logo.php Code: [Select] <?php <form enctype="multipart/form-data" method="post" action="uploaded_logo.php"> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> <tr> <td>Choose a Logo to Upload: </td> <td><input name="uploaded_file" type="file" /></td> </tr> <tr> <td> </td> <td><input type="submit" value="Upload File" name="submit>"</td> </tr> </form> ?> uploaded_logo.php Code: [Select] <?php if($_FILES['uploaded_file']["type"] == "image/gif") { $target_path = "logo/"; $target_path = $target_path. basename($_FILES['uploaded_file']['name']); if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $target_path)) { echo "<span class=\"error_validation\">The Logo has been successfully changed!<br></span>"; echo "<span class=\"error_validation\">Upload Logo Again? <a href=\"edit_logo.php\">Click Here</a><br></span>"; } else { echo "<span class=\"error_validation\">There was an error uploading the logo. Pls. try again.<br></span>"; echo "<span class=\"error_validation\">Upload Logo Again? <a href=\"edit_logo.php\">Click Here</a><br></span>"; } } else { echo "<span class=\"error_validation\">Invalid file format. We are only accepting image file. Pls. try again.<br></span>"; echo "<span class=\"error_validation\">Upload Logo Again? <a href=\"edit_logo.php\">Click Here</a><br></span>"; } ?> So what the code suppose to do is.. If I upload an image file as the new logo it should have the default logo name "my_logo.gif", then it will overwrite the existing one... Anyone? Why does the following code not detect the following file? After I select a file and I click upload, it goes back to the upload form. <?php include_once("includes/config.php"); //grab their type if(!$_COOKIE['user']) { //they are a guest $info = "Guest"; } else { //they are a user $info = $_COOKIE['user']; } if(!$_FILE['file']) { $content = '<form action="submit.php" method="post" enctype="multipart/form-data"> <label for="file">SELECT SKIN:</label> <input type="file" name="file" id="file" /> <input type="submit" name="submit" value="Submit" /> </form>'; } else { if($_FILES['file']['error'] > 0) { $content = "There was an error trying to upload the skin ".$_FILES['file']['name'].".".$_FILES['file']['error']; } } ?> <html> <head> <title><?php $title; ?></title> <link rel="stylesheet" type="text/css" href="theme/style.css" /> </head> <body> <div id="header"> MCSkins </div> <?php echo "Submitting as: ".$info."<br/><br/>".$content; ?> </body> </html> Hello dear friends, i've very simple php script for my website and it has feature that visitor can register and upload image for own profile. somone has uploaded PHP Shell as image and succeed to control on my website using that shell. so the problem is in uploading image can pass any file so can someone please help me how how to prevent it and here are the codes of image upload form and function. * Image upload form code Code: [Select] <form action="profile.php" method="post" enctype="multipart/form-data" name="form" id="form"> My Picture : <input name="userpic" type="file" id="userpic"/> <input type="submit" name="Submit" value="Update"/> * Profile.php code (it rename the image by add time to its name then put the image in path /users/ then insert the new name of the image into the database table) $ImageName = $_FILES[userpic][name]; // Get the image $t = time(); // Get Time $NewImageName = "$t$ImageName"; // New name copy($_FILES[userpic][tmp_name], "users/$NewImageName"); $sql= "update users SET userpic='$NewImageName'"; How then i can stop they upload shell thanks Hi everyone, im a newbie and have written this script, has taken me a day to get here. The form inserts data into the database, uploads a file and sends an email. All this works fine, what i am trying to do is rename the file to the id of the record and check to make sure it is a pdf. I would really appreciate any help. I've tried and tried and just cant get it to work. <?php switch ($_REQUEST['action']) { case 'recruit': foreach($_POST as $key=>$value){ $$key = $value; } if ((!$name) || (!$email) || (!$phone)) { $error_msg = 'Fields marked<span class="gold"> * </span>are required to submit the form'; }elseif (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) { $error_msg = 'Invalid email address'; } echo "$error_msg","<br><br>"; if ($error_msg == ''){ $date=date("d/m/y", time()); $add="recruitment/".$_FILES[userfile][name]; $cleaned = stripit($add); $add2 = $cleaned; if(move_uploaded_file ($_FILES[userfile][tmp_name], $add2)); $Q = mysql_query("INSERT INTO recruitment (`name`,`phone`,`email`, `qual`,`exper`,`file`) VALUES ('$name','$phone','$email','$qual','$exper','$cleaned')"); foreach($_POST as $key=>$value){ $$key = htmlentities(stripslashes($value)); } $companyname = 'Mead Business college'; $companyemail = 'ross@emediastudios.com.au'; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: ".$name." <".$email.">\r\n"; $headers .= "Reply-To: ".$name." <".$email.">\r\n"; $to = "".$companyname."<".$companyemail.">"; $subject = "Mead Business College Recruitment Form Submission"; $message = '<style type="text/css>"; <!-- .style { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; } --> </style> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="style"> <b>Details:</b><br /><br /> <b>Name:</b> '.$name.'<br /> <b>Email:</b> '.$email.'<br /> <b>Mobile No:</b> '.$phone.'<br /> <b>Qualifications:</b><br> '.$qual.'<br /> <b>Experience:</b><br /><br />'.$exper.'<br /><br /> <b>Uploaded resume:</b> http://www.mydomain.com.au/'.$cleaned.' </td> </tr> </table>'; mail($to, $subject, $message, $headers); echo '<table width="99%" border="0" cellpadding="0" cellspacing="0"> <tr> <td class="mybody">Hi '.$name.',<p />Thank you for your enquiry. An MBC Consultant will contact you shortly.<br /> <br /> </td> </tr> </table>'; }else{ foreach($_POST as $key=>$value){ $$key = htmlentities(stripslashes($value)); } echo ' <FORM ENCTYPE="multipart/form-data" id="form" name="Contact Form" method="post" action="'.$_SERVER['PHP_SELF'].'?action=recruit"> <table width="489" border="0" cellspacing="5" cellpadding="0" class="formsw"> <tr> <td width="227">Name:</td> <td width="358"><input type="text" name="name" id="name" value="'.$name.'" /></td> </tr> <tr> <td>Contact Mobile:</td> <td><input type="text" name="phone" id="phone" value="'.$phone.'" /></td> </tr> <tr> <td>Email:</td> <td><input type="text" name="email" id="email" value="'.$email.'" /></td> </tr> <tr> <td>Relevent Qualifications:</td> <td><textarea name="qual" id="qual" cols="45" rows="5" value="'.$qual.'"></textarea></td> </tr> <tr> <td>Recent Experience:</td> <td><textarea name="exper" id="exper" cols="45" rows="5" value="'.$exper.'"></textarea></td> </tr> <tr> <td>Upload Resume:</td> <td><input type="file" name="userfile" id="userfile" /></td> </tr> <tr> <td><input type="submit" name="submit" id="submit" value="Submit" /></td> <td> </td> </tr> </table> </form>'; } break; } ?> Please, I need help with resizing uploaded images. Copied below is the code for image upload ( which I tagged "upload.php") Code: [Select] <?php // define a constant for the maximum upload size define ('MAX_FILE_SIZE', 51200); if (array_key_exists('upload', $_POST)) { // define constant for upload folder define('UPLOAD_DIR', 'C:/upload_test/'); // convert the maximum size to KB $max = number_format(MAX_FILE_SIZE/1024, 1).'KB'; // create an array of permitted MIME types $permitted = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png'); foreach ($_FILES['image']['name'] as $number => $file) { // replace any spaces in the filename with underscores $file = str_replace(' ', '_', $file); // begin by assuming the file is unacceptable $sizeOK = false; $typeOK = false; // check that file is within the permitted size if ($_FILES['image']['size'][$number] > 0 || $_FILES['image']['size'][$number] <= MAX_FILE_SIZE) { $sizeOK = true; } // check that file is of an permitted MIME type foreach ($permitted as $type) { if ($type == $_FILES['image']['type'][$number]) { $typeOK = true; break; } } if ($sizeOK && $typeOK) { switch($_FILES['image']['error'][$number]) { case 0: // check if a file of the same name has been uploaded // if (!file_exists(UPLOAD_DIR.$file)) { // move the file to the upload folder and rename it $success = move_uploaded_file($_FILES['image']['tmp_name'][$number], UPLOAD_DIR.$file); // } /* else { // get the date and time ini_set('date.timezone', 'Europe/London'); $now = date('Y-m-d-His'); $success = move_uploaded_file($_FILES['image']['tmp_name'][$number], UPLOAD_DIR.$now.$file); }*/ if ($success) { $result[] = "$file uploaded successfully"; } else { $result[] = "Error uploading $file. Please try again."; } break; case 3: $result[] = "Error uploading $file. Please try again."; default: $result[] = "System error uploading $file. Contact webmaster."; } } elseif ($_FILES['image']['error'][$number] == 4) { $result[] = 'No file selected'; } else { $result[] = "$file cannot be uploaded. Maximum size: $max. Acceptable file types: gif, jpg, png."; } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Multiple file upload</title> </head> <body> <?php // if the form has been submitted, display result if (isset($result)) { echo '<ol>'; foreach ($result as $item) { echo "<strong><li>$item</li></strong>"; } echo '</ol>'; } ?> <form action="" method="post" enctype="multipart/form-data" name="multiUpload" id="multiUpload"> <p> <label for="image1">File 1:</label> <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo MAX_FILE_SIZE; ?>" /> <input type="file" name="image[]" id="image1" /> </p> <p> <label for="image2">File 2:</label> <input type="file" name="image[]" id="image2" /> </p> <p> <input name="upload" type="submit" id="upload" value="Upload files" /> </p> </form> </body> </html> This works fine , except that it only uploads to C:/upload_test instead of the images folder (../img/) Can you please help with the codes for creating thumbnails while retaining the original upload. Thanks I have this script where it uploads the file name to a database plus a few more things. Main Upload form. (img_add.php) <form enctype="multipart/form-data" action="img_add.php" method="POST"> Name: <input type="text" name="name"><br> E-mail: <input type="text" name = "email"><br> Phone: <input type="text" name = "phone"><br> Photo: <input type="file" name="photo"><br> <input type="submit" value="Add"> </form> Uploader. (img_add.php) <?php //This is the directory where images will be saved $target = "mainnewsimg/"; $target = $target . basename( $_FILES['photo']['name']); //This gets all the other information from the form $name=$_POST['name']; $email=$_POST['email']; $phone=$_POST['phone']; $pic=($_FILES['photo']['name']); // Connects to your Database mysql_connect("localhost", "root", "") or die(mysql_error()) ; mysql_select_db("chat") or die(mysql_error()) ; //Writes the information to the database mysql_query("INSERT INTO `images` VALUES ('$name', '$email', '$phone', '$pic')") ; //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //Tells you if its all ok echo "The file ". basename( $_FILES['photo']['name']). " has been uploaded, and your information has been added to the directory"; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } ?> And the one that views it. (img_view.php) It uses a get function so do it with img_view.php?img=2 <?php mysql_connect("localhost", "root", "") or die(mysql_error()) ; mysql_select_db("chat") or die(mysql_error()) ; //Retrieves data from MySQL $newsid = $_GET['img']; $data = mysql_query("SELECT * FROM `images` WHERE id ='$newsid'") or die(mysql_error()); //Puts it into an array while($info = mysql_fetch_array( $data )) { //Outputs the image and other data Echo "<img src=mainnewsimg/".$info['photo'] ."> <br>"; } ?> And my database sql. CREATE TABLE IF NOT EXISTS `images` ( `name` varchar(30) DEFAULT NULL, `email` varchar(30) DEFAULT NULL, `phone` varchar(30) DEFAULT NULL, `photo` varchar(30) DEFAULT NULL, `id` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; -- -- Dumping data for table `images` -- INSERT INTO `images` (`name`, `email`, `phone`, `photo`, `id`) VALUES ('sdf', 'sdfdsdsf', 'dsffsfsdf', 'arrow_forward_last.gif', 1), ('sadd', 'sadd', 'adsadasdad', 'artbottomshadr.png', 2); The values inside I had to put in manually to test if it worked for the img_view.php Anyways, It doesnt want to upload the images at all, even tho it says it did and gives the message The file ". basename( $_FILES['photo']['name']). " has been uploaded, and your information has been added to the directory I would greatly appreciate some help, I also provided everything so you can try it on your own server too. Hi Everyone, I've been studying the topics at this site and others on ways to count uploaded images; and what I've tried hasn't worked. I have seen this question posed and answered many times and most of the answers are something akin to this: Code: [Select] $count = count($_FILES['userfile'] ['name']); echo "the number of photos is ".$count; The explanation usually states that "count($_FILES['userfile'])" will simply count the number of elements in the array and return 5. But including ['name'] will return the number of files (images) uploaded. I will allow up to five photos to be uploaded (less is OK too) and want to count them in order to iterate through the proper number of loops to filter and process the photos. I've tested both of the above and get 5 (elements) when I count the ['userfile']; but get 0 (zero) when I test "['userfile'] ['name']". Here's the html code: Code: [Select] <!-- html here to input form data --> <label></label><input type="hidden" name="MAX_FILE_SIZE" value="500000000" /><br /> <label for="userfile">Upload photo 1</label> <input type="file" name="userfile1" id="userfile1" /><br /> <label for="userfile">Upload photo 2</label> <input type="file" name="userfile2" id="userfile2" /><br /> <label for="userfile">Upload photo 3</label> <input type="file" name="userfile3" id="userfile3" /><br /> <label for="userfile">Upload photo 4</label> <input type="file" name="userfile4" id="userfile4" /><br /> <label for="userfile">Upload photo 5</label> <input type="file" name="userfile5" id="userfile5" /><br /><br /> <label></label><input type="submit" name="userfile" value="Send Ad" /> </form> I've been testing the uploads with two files (jpg) and have tried to come up with an alternative that can iterate through the file arrays and determine how many photos I have. The code I've been testing is as follows: Code: [Select] $num = 1; $count = 0; while ($num <=5) { foreach ($_FILES['userfile'.$num] as $upload){ if ($upload ['error'] != 4){ } $count ++; } $num++; } echo "the number of photos is ".$count; I'm using "['error'] !=4" because some times people won't have 5 photos to upload. The result I get is 25 or 5 (files) x 5 (elements) for a total of 25. Does anyone know the proper way of doing this? Thanks for you input! Cheers, Rick Hi Guys, I have this script below which inserts the file name and path into my datebase and uploads the file into the customers folders (which is creates dynamically). The is no error checking as I want it to be as flexible as possible but mostly(99.999%) the files I upload are JPEG and PDF's. I would like my script to be able to resize the files above automatically to be smaller. Please is this possible thanks! Here is script: <?php //Will create a directory once a customer is clicked and will not if page is refreshed an so forth if (file_exists('customerUploads/' . $check_id . ', ' . $c_name . '')) { } else { mkdir('customerUploads/' . $check_id . ', ' . $c_name . ''); } ?> <?php //This php block of code will takecare of inserting the upload variables into the db if(isset($_POST['submitbutton'])) { $target_path = 'customerUploads/' . $check_id . ', ' . $c_name . '/'; $target_path = str_replace("'","",$target_path); $target_path = $target_path . basename( $_FILES['upload']['name']); $manager= mysql_real_escape_string($_POST['username']); $upload = $_FILES['upload']['name']; $upload = str_replace("'","",$upload); $check_id = mysql_real_escape_string($_POST['id']); $submitbutton= mysql_real_escape_string($_POST['submitbutton']); if($submitbutton) { if($manager&&$upload) { if (file_exists($target_path)) { echo $_FILES["upload"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["upload"]["tmp_name"],$target_path); echo "Stored in: " . 'customerUploads/' . $check_id . ', ' . $c_name . '/' . $_FILES["upload"]["name"]; $insert=mysql_query("INSERT INTO img_up (username,upload,id,target_path,img_date) VALUES ('$manager','$upload','$check_id','$target_path', now()) "); // Where the file is going to be placed $target_path = 'customerUploads/' . $check_id . ', ' . $c_name . '/'; /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $target_path = $target_path . basename( $_FILES['upload']['name']); $target_path = 'customerUploads/' . $check_id . ', ' . $c_name . '/'; $target_path = $target_path . basename( $_FILES['upload']['name']); if (file_exists($target_path)) { echo $_FILES["upload"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["upload"]["tmp_name"],$target_path); echo "Stored in: " . 'customerUploads/' . $check_id . ', ' . $c_name . '/' . $_FILES["upload"]["name"]; } } } else { echo "There was an error uploading the file, please try again!"; } } header("location: mainupload_complete.php?id=$check_id"); } ?> |