PHP - Multiple Directory File Uploader
Hi,
Ive had a website for some time that allows people to upload pictures to certain directories, and each directory had its own upload script, I decided as Im slowley getting better at php to combine it all into 1 file and include it, all works great, but now I notice its a lot of repeated code as the only thing that changes for each function is the directory name, here is the script as it is: <?php // James Davies, Revised 2010 // Create the main NSFW upload function function demotivate() { //configure site specific variables $website = 'http://www.thenudedeer.com'; //what is the folder name $phpbbdir = '/demotivate/'; // Create an array containing all valid upload file types for this script $allowed_types = array( "image/gif" => "gif", "image/pjpeg" => "jpg", "image/jpg" => "jpg", "image/jpeg" => "jpg", "image/png" => "png", "image/x-png" => "png", // Add more types here if you like ); // Check to see if the file type is in the allowed types array if(!array_key_exists($_FILES['userfile']['type'], $allowed_types)) { die("Invalid file type."); } // Set the maximum uploadable file size => 512000 = 500kb $maxfilesize = 512000; // Is the file larger than it is allowed to be? if($_FILES['userfile']['size'] > $maxfilesize) { die("File too large"); } // Where will the file be uploaded to? $uploaddir = $_SERVER['DOCUMENT_ROOT'] . $phpbbdir; // What is the files temporary name? $file = $_FILES['userfile']['tmp_name']; // What is the files actual name? $filename = $_FILES['userfile']['name']; // Does this file already exist on the server? if(file_exists($uploaddir . $filename)) { //die("A file with that name already exists on this server."); die("File already existed, [img]http://" . $website . $phpbbdir . $filename ."[/img]"); } else { // This file does not already exist, so copy it. copy($file, $uploaddir.$filename) or die("Could not copy file."); } // All done! :-) echo "<br />"; echo "<font color=red><b>"; echo "Upload successful"; echo "<br />"; echo "Copy and Paste the following Code"; echo "</font><br/>"; echo "<font color='green'><b>"; echo "<br />"; echo "[img]http://" . $website . $phpbbdir . $filename; echo "[/img]"; echo "<br/>"; echo "<br/>"; echo '<img class="img" src="' .$phpbbdir .$filename.'">'; echo "<br />"; echo "<br />"; echo "</font>"; echo "<br /><br />"; } function nsfw() { //configure site specific variables $website = 'http://www.thenudedeer.com'; //what is the folder name $phpbbdir = '/nsfw/'; // Create an array containing all valid upload file types for this script $allowed_types = array( "image/gif" => "gif", "image/pjpeg" => "jpg", "image/jpg" => "jpg", "image/jpeg" => "jpg", "image/png" => "png", "image/x-png" => "png", // Add more types here if you like ); // Check to see if the file type is in the allowed types array if(!array_key_exists($_FILES['userfile']['type'], $allowed_types)) { die("Invalid file type."); } // Set the maximum uploadable file size => 512000 = 500kb $maxfilesize = 512000; // Is the file larger than it is allowed to be? if($_FILES['userfile']['size'] > $maxfilesize) { die("File too large"); } // Where will the file be uploaded to? $uploaddir = $_SERVER['DOCUMENT_ROOT'] . $phpbbdir; // What is the files temporary name? $file = $_FILES['userfile']['tmp_name']; // What is the files actual name? $filename = $_FILES['userfile']['name']; // Does this file already exist on the server? if(file_exists($uploaddir . $filename)) { //die("A file with that name already exists on this server."); die("File already existed, [img]http://" . $website . $phpbbdir . $filename ."[/img]"); } else { // This file does not already exist, so copy it. copy($file, $uploaddir.$filename) or die("Could not copy file."); } // All done! :-) echo "<br />"; echo "<font color=red><b>"; echo "Upload successful"; echo "<br />"; echo "Copy and Paste the following Code"; echo "</font><br/>"; echo "<font color='green'><b>"; echo "<br />"; echo "[img]http://" . $website . $phpbbdir . $filename; echo "[/img]"; echo "<br/>"; echo "<br/>"; echo '<img class="img" src="' .$phpbbdir .$filename.'">'; echo "<br />"; echo "<br />"; echo "</font>"; echo "<br /><br />"; } function fail() { //configure site specific variables $website = 'http://www.thenudedeer.com'; //what is the folder name $phpbbdir = '/fail/'; // Create an array containing all valid upload file types for this script $allowed_types = array( "image/gif" => "gif", "image/pjpeg" => "jpg", "image/jpg" => "jpg", "image/jpeg" => "jpg", "image/png" => "png", "image/x-png" => "png", // Add more types here if you like ); // Check to see if the file type is in the allowed types array if(!array_key_exists($_FILES['userfile']['type'], $allowed_types)) { die("Invalid file type."); } // Set the maximum uploadable file size => 512000 = 500kb $maxfilesize = 512000; // Is the file larger than it is allowed to be? if($_FILES['userfile']['size'] > $maxfilesize) { die("File too large"); } // Where will the file be uploaded to? $uploaddir = $_SERVER['DOCUMENT_ROOT'] . $phpbbdir; // What is the files temporary name? $file = $_FILES['userfile']['tmp_name']; // What is the files actual name? $filename = $_FILES['userfile']['name']; // Does this file already exist on the server? if(file_exists($uploaddir . $filename)) { //die("A file with that name already exists on this server."); die("File already existed, [img]http://" . $website . $phpbbdir . $filename ."[/img]"); } else { // This file does not already exist, so copy it. copy($file, $uploaddir.$filename) or die("Could not copy file."); } // All done! :-) echo "<br />"; echo "<font color=red><b>"; echo "Upload successful"; echo "<br />"; echo "Copy and Paste the following Code"; echo "</font><br/>"; echo "<font color='green'><b>"; echo "<br />"; echo "[img]http://" . $website . $phpbbdir . $filename; echo "[/img]"; echo "<br/>"; echo "<br/>"; echo '<img class="img" src="' .$phpbbdir .$filename.'">'; echo "<br />"; echo "<br />"; echo "</font>"; echo "<br /><br />"; } ?> there must be a way to stop repeating all the same code for each function? many thanks Similar TutorialsThis has probably been asked here tons of times, and yes I've searched on google but I can't find a decently explained method. What I want is to be able to upload a whole directory of pictures at once. These pictures must go through the following: Be cropped in size (about 600px width/height) This must be stored in a folder under a random name A thumbnail must be made, with the same name, in another folder The location of each picture should be stored in a database What I've said here is all PHP I presume, and that I can take care of, I think. The problem is the multiuploader. I understand it can't be done in PHP, since PHP lets only 1 file per input tag, so you cannot select a directory. So this should be done with javascript/java/??? Additional questions: if I do mkdir('/pictures/$mapname/thumbs');, the 'pictures' already exists but the rest doesn't. Does it create the $mapname dir and the thumbs, or should I use 2 different mkdir's? What width is best to save the images to? What with is the best to save the thumbs to? So many more, but I'll keep it at this! I know it's a lot of questions, but it would really be handy if I could do this! Thanks in advance! Hi: I have written code that will allow a user to upload a file and that will allow the user to view/delete the image when clicking on the link. I'm having trouble in the table where the image information is organized - the table just duplicates information about an image into another column,.how can I fix this? Here's my code: Code: [Select] <? if ($handle = opendir('images/')) { while (false !== ($file = readdir($handle))) { $TPL['fileList'][] = array( 'fileName' => $file, 'fileSize' => filesize('images/'.$file), 'fileDate' => 'Jan 2, 2029' ); } } switch ($_REQUEST['act']): default: break; if (empty($_FILES['userfile']['name'])): $TPL['errMsg'] = "No file selected"; $TPL['dispErrMsg'] = true; break; endif; copy ($_FILES['userfile']['tmp_name'], 'images/'.$_FILES['userfile']['name']); break; case 'del': echo "delete this file? ($_GET)['userfile']['name']"; endswitch; ?> <html> <head> <title>Comp10065 - Lab 4: File Upload</title> <style type="text/css"> body {background-color:yellow} div#container {margin-right: auto; margin-left: auto; border: 1px solid #EEEEEE; width: 800px; padding: 10px; background-color:white} h1 {text-align: center; color:orange; background-color:white} table {width: 700px; margin-bottom: 15px} table th {text-align: left;padding: 0px 10 0px 10px} table td{padding: 0px 10 0px 10px; border: 1px solid #AAAAAA} tr.odd {background-color: #EEEEEE} tr.even {background-color: #CCCCCC} .message {color:red} div#debug {border: 1px solid #BBBBBB} </style> <script language="JavaScript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.js"></script> <script type="text/javascript"> function popup(img) { var day= new Date(); var windowParms = 'width=400,height=400,scrollbars,resizable'; var htmlPage = '<html><body><img src="' + img + '"><br>' + ' <form><input type="button" ' + ' onclick="javascript:window.close();" value="Close Window"><br>\n' + ' </form></body></html>\n'; var popupWindow = window.open('',day.getTime(),windowParms); popupWindow.document.write(htmlPage); popupWindow.document.close(); } </script> <script> $(function() { $("div#debug").hide(); $("a#debugLink").click(function () {$("div#debug").toggle("slowly"); }); }); </script> </head> <body > <div id="container"> <h1> Picture Uploader!</h1> <p>Click here to <a href="<?= $_SERVER['PHP_SELF'] ?>">refresh</a> this page.</p> <table> <tr> <th>File Name (<a href="upload.php?act=sortby&col=filename">sort</a>)</th> <th>Size KBytes (<a href="upload.php?act=sortby&col=size">sort</a>)</th> <th>Date</th> </tr> </td> <? foreach($TPL['fileList'] as $key => $val): ?> <td><a href="<?= 'images/'.$val['fileName'] ?>"><?=$val['fileName'] ?></a></td> <td><?= $val['fileName'] ?></td> <td><?= $val['fileSize'] ?></td> <td><?= $val['fileDate'] ?></td> <td><a href="#" onClick="popup('images/uieiuirdi.jpg')" >View</a></td> <td align=center><a href=upload.php?act=del&file=uieiuirdi.jpg>Delete</a></td> </tr> <? endforeach ?> </table> <p class="message">Records sorted by size</p> <form action=upload.php method="post" enctype='multipart/form-data'> <input type="hidden" name="MAX_FILE_SIZE" value="2000000"> <input type="hidden" name="act" value="post"> <input type="file" name="userfile" size="60" value=""> <br> <input type="submit" value="UPLOAD FILE" name="submit">Do not upload large files! </form> <? if($TPL['dispErrMsg']): ?> <p><?= $TPL['errMsg'] ?></p> <? endif; ?> <hr> <p>Click <a href="#" id = "debugLink"> here </a> for debug info. Jquery show/hide effect.</p> <div id="debug"> <p>This debug info is here to help you. You are only required to display the $_POST and $_FILES array</p> <pre > <? print_r($TPL) ?></pre> </div> </div> </body> </html> dear folks
this question is regarding the plugin update, file uploader and SFTP - on a wordpress that runs on secured- server
I think I know the answer to the following question as "not possible" but I figured I would check. my sites are on servers where we disable FTP access and only use SFTP access, and also on a different port (not port 22). what if i want to use a automated maintaining service like the following https://mainwp.com http://wwww.infinitewp.com automated Installing and updating plugins to the sites does not seem to work and I assume this is the reason why. I'm also assuming the File uploader extension will not work either. Can anyone confirm this for sure though? Any ideas as far as workaround? one might think of the following way: Can you try adding your SFTP settings into the wp-config of one of my sites to see if that allows the functions to work? we can see an example in http://codex.wordpre...g_wp-config.php under WordPress Upgrade Constants or possibly try this plugin SSH SFTP Updater Support do you have any idear!? cf: https://mainwp.com/f...&highlight=sftp I havent included the whole title as it wouldnt let me but I was wondering if someone could help me on this? I know this is possible as torrentflux caters for this but unsure of where to start. I dont want to allow file or directory uploads or creation in my /etc/php.ini file (this is turned off). Yet then torrentflux allows me to link a torrent from an external source (using legal downloads of course ) but then it uploads it on my server and creates folders on a per user basis. How is this possible can someone give me some pointers please? I look forward to any replies, Jeremy. Good day.
I have just written my first php phpexcell file importing into mysql without errors. now my next step is to try and read multiple excell files in a directory " files are same format" and import into mysql.
Heres my code so far.
<?php $db_host = "localhost";$db_user = "root";$db_pass = "";$db_name ="kk";$db_table = "test"; require '/Classes/PHPExcel.php'; require_once '/Classes/PHPExcel/IOFactory.php'; $objPHPExcel = PHPExcel_IOFactory::load('Amersfoort_WR.xlsx'); foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) { $worksheetTitle = $worksheet->getTitle(); $highestRow = $worksheet->getHighestRow(); // e.g. 10 $highestColumn = $worksheet->getHighestColumn(); // e.g 'F' $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn); $nrColumns = ord($highestColumn) - 64; echo "File ".$worksheetTitle." has "; echo $nrColumns . ' columns'; echo ' y ' . $highestRow . ' rows.'; echo "$cellValue"; $link = mysql_connect($db_host,$db_user,$db_pass); if(!$link) die ('Could not connect to database: '.mysql_error()); mysql_select_db($db_name,$link); for ($row = 2; $row <= $highestRow; ++ $row) { $val=array(); for ($col = 0; $col < $highestColumnIndex; ++ $col) { $cell = $worksheet->getCellByColumnAndRow($col, $row); $val[] = $cell->getValue(); } $sql = "insert into test (F1, F2, F3, F4) values('".$val['0']."', '".$val['1']."', '".$val['2']."','".$val['3']."')"; mysql_query($sql); } } mysql_close($link); ?> I'm in the middle of making my own CMS system, where a user can create a page online via a text editor, I know how to create and save the file, but to make the process easier I would like to a function where a user can click a button find a list of files and folders, pick the folder location to save a new file to. Instead of having to type something like this /commonPages/aboutUs/ with the file name being test.php What would be the easiest way to do this? I have just been looking at opendir() and my first thought was to use <input type="file" />, but then I remember that was only for inputting a particular file name, which would be useful for renaming a file at a later date. For example, if we wanted to change test.php to something more meaningful ie history.php Why does this code: Code: [Select] require_once "../../media/php/classes/Mysql.inc.php"; Work when I go to: http://mysite.com/API/v1/index.php But when I go to: http://mysite.com/index.php it doesn't work. The require is being called from another class, which I call from the two pages above. The class loads, but in the second link, I get failed to open stream: No such file or directory but the first one works fine. What would cause this? could this be an htaccess thing? htaccess: Code: [Select] Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.+)$ /$1.php [L,QSA] In my script, I'm trying to create a file with the name of a variable in a different directory. My code is: Code: [Select] $handle = fopen("cheese/" . $page . ".html", "w");Output: Warning: fopen(cheese/test.html) [function.fopen]: failed to open stream: No such file or directory in /home/a5938041/public_html/newfile/newpage.php on line 6 What's happening here? (sorry I'm a total noob.) I have a file system browser i'm writing for a client. I would like to know if there's a way to determine if an object is a directory or file, so I can display a proper icon next to it depending on what it is. Any help is appreciated. Hi,
I have this code
<?php // Must include this include("geoiploc.php"); function getYJLINKS($default_font_family,$yj_copyrightear,$yj_templatename,$show_tools,$show_fres,$show_rtlc,$validators_off,$totop_off){ $allLinks = array(); if((function_exists('toolbox_urls') && $show_tools == 1) || $validators_off == 1 || $totop_off == 1){ echo '<div class="validators">'; if($validators_off == 1){ $allLinks[] ='<a href="http://jigsaw.w3.org/css-validator/check/referer?profile=css3" target="_blank" title="CSS Validity">CSS Valid</a>'; $allLinks[] ='<a href="http://validator.w3.org/check/referer" target="_blank" title="XHTML Validity">XHTML Valid</a>'; } if($totop_off == 1){ $allLinks[] ='<a class="yjscroll" href="#stylef'.$default_font_family.'">Top</a>'; } if (function_exists('toolbox_urls') && $show_tools == 1): global $font_size; global $font_direction; if ($show_fres == 1): $allLinks[] = '<a id="fontSizePlus" class="fs" href="javascript:;" rel="nofollow">+</a>'; $allLinks[] = '<a id="fontSizeMinus" class="fs" href="javascript:;" rel="nofollow">-</a>'; $allLinks[] = '<a id="fontSizeReset" class="fs" href="javascript:;" rel="nofollow">reset</a>'; endif; if ($show_rtlc == 1): $allLinks[] = '<a class="tdir" href="'.$font_direction[1].'" rel="nofollow">RTL</a>'; $allLinks[] = '<a class="tdir" href="'.$font_direction[2].'" rel="nofollow">LTR</a>'; endif; endif; echo implode(' | ',$allLinks); echo '</div>'; } // loading this from a database $ip = $_SERVER["REMOTE_ADDR"]; // listing Country Flags Images $dir = 'images/flags'; $file_display = array('png'); if (file_exists ($dir) == false) { echo 'Directory \'', $dir, '\' not found!'; } else{ $dir_contents = scandir($dir); foreach($dir_contents as $file) { $file_type = strtolower(end(explode('.', $file))); If($file !== '.' && $file !== '..' && in_array($file_type, $file_display) == true) if($file == '..' || $file == '.') { continue; } $code = strtolower(getCountryFromIP($ip, "code")); echo '<div class="yjsgcp">Palana.it ® 1994 - '.$yj_copyrightear.' :: Tutti i diritti riservati :: Realizzazione Palana.it ││ Utente rilevato: IP: '. $ip . ', '.getCountryFromIP($ip, " NamE ").' ('.getCountryFromIP($ip, "code").'-'.getCountryFromIP($ip, "AbBr").') '; echo '<img src="', $dir, '/', $code, '.png" /> </div>'; } } } ?>The problem, as we see (http://www.palana.it), is that code printed the Italian flag but many times there are images in the directory, that is over 204. See bottom of the page. How can I fix the code to get ONE display? $file="../myclients/clients/".$company_name."/Download/".$file_name; $size = filesize($path); // not working i try with function also function formatbytes($file, $type) { switch($type){ case "KB": $filesize = filesize($file) * .0009765625; // bytes to KB break; case "MB": $filesize = (filesize($file) * .0009765625) * .0009765625; // bytes to MB break; case "GB": $filesize = ((filesize($file) * .0009765625) * .0009765625) * .0009765625; // bytes to GB break; } if($filesize <= 0){ return $filesize = 'unknown file size';} else{return round($filesize, 2).' '.$type;} } echo formatbytes($file, "KB"); uploaded file size is 488 kb but it showing "unknown file size" please help me. file_get_contents() has suddenly stopped working for me. I keep getting this error: Code: [Select] Warning: file_get_contents(/Users/ttocskcaj/MineCMS/public/js/jquery.js ) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: No such file or directory in /Users/ttocskcaj/MineCMS/controllers/m.controller.php on line 44 The file(s) definitely exist, I can use nano to open them, and permissions are 777 on all the files. The lampp error log has nothing. Not even a No such file or directory error as you'd expect. Any ideas what's going on? After a user on my site deletes their account I want their profile picture to be deleted from my images folder. I was testing the unlink function on my index.php file and it is failing. Here is the error: Warning: unlink(/assets/img/avatars/users/jasongordon.png): No such file or directory in /home/www-data/big.com/index.php on line 86 My code was just: unlink('/assets/img/avatars/users/jasongordon.png'); I'm not sure why this fails because my file does exist. Hey, I dont know whats wrong but i was hoping someone could take a look at the code and provide some errors that maybe causing this script not to work. I want it to display all the .jpg pictures in thumbnails, it currently does not even get the pictures. code: <?php $pic_listing = mysql_query("SELECT * FROM toplist WHERE id='". $id ."'") or die(mysql_error()); while($serverpic = mysql_fetch_array($pic_listing)) { $servername = $serverpic["servername"]; } $directory = "images/serverpic/" . $servername . ""; $images = glob("" . $directory . "*.jpg"); if(empty($images)) { ?> <div class="highslide-gallery"> <?php foreach($images as $image) { ?> <a href="images/serverpic/<?php echo $servername . "/" . $image; ?>" class="highslide" onclick="return hs.expand(this)"> <img src="images/serverpic/<?php echo $servername . "/" . $image; ?>" alt="Highslide JS" width="100" height="100" title="Click to enlarge" /> </a> <div class="highslide-caption"> <?php } ?> </div> </div> <?php } ?> hey guys im tyring to read my directory (whole of the web server)...i want to be able to put the file name and root into an array...im just wanting to know whats the best function i need to do this please?...thank you This one stumped me, but maybe someone has figured it out. I'm trying to write a script that is able to decide whether a remote url is a directory or a file, this is fine until it comes to mod_rewrite(rewritten?) urls. ex. http://www.example.com/test Now this could be test.php,test.html etc., but in the rare case, it could also be a folder (example.com/test/index.php). Anyone have any ideas? The code works but it puts the files into /uploadir/. The users directories go by their email addresses ($email). Good Evening, If anyone could help with this little problem be much appreciated. what i'm trying to do is using a drop down menu select a folder name which is stored in a database table.. then taking that folder name and upload various files to that specified folder. There's probably an easier way to do this but i've searched google argggh.. The first part of code is the php to grab the folder names and the file selection form Code: [Select] <?php include("connection.php"); $sql="SELECT id, name FROM gallery"; $result=mysql_query($sql); $options=""; while ($row=mysql_fetch_array($result)) { $id=$row["id"]; $thing=$row["name"]; $options.="<OPTION VALUE=\"$id\">".$thing ; } ?> <table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form action="postFiles.php" method="post" enctype="multipart/form-data" name="form1" id="form1"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td><strong>multiple Files Upload </strong></td> </tr> <td><SELECT NAME=thing> <OPTION VALUE=0>Choose <?=$options?> </SELECT> </td> <tr> <td>Select file <input name="ufile[]" type="file" id="ufile[]" size="50" /></td> </tr> <tr> <td>Select file <input name="ufile[]" type="file" id="ufile[]" size="50" /></td> </tr> <tr> <td>Select file <input name="ufile[]" type="file" id="ufile[]" size="50" /></td> </tr> <tr> <td align="center"><input type="submit" name="Submit" value="Upload" /></td> </tr> </table> </td> </form> </tr> </table> The second part of the code below is the php code to upload those files, the problem being how do i specify the upload destination using the drop down in the previous form (instead of UPLOAD) which it is default set to Code: [Select] <?php //set where you want to store files //in this example we keep file in folder upload //$HTTP_POST_FILES['ufile']['name']; = upload file name //for example upload file name cartoon.gif . $path will be upload/cartoon.gif $path1= "upload".$HTTP_POST_FILES['ufile']['name'][0]; $path2= "upload".$HTTP_POST_FILES['ufile']['name'][1]; $path3= "upload".$HTTP_POST_FILES['ufile']['name'][2]; //copy file to where you want to store file copy($HTTP_POST_FILES['ufile']['tmp_name'][0], $path1); copy($HTTP_POST_FILES['ufile']['tmp_name'][1], $path2); copy($HTTP_POST_FILES['ufile']['tmp_name'][2], $path3); //$HTTP_POST_FILES['ufile']['name'] = file name //$HTTP_POST_FILES['ufile']['size'] = file size //$HTTP_POST_FILES['ufile']['type'] = type of file echo "File Name :".$HTTP_POST_FILES['ufile']['name'][0]."<BR/>"; echo "File Size :".$HTTP_POST_FILES['ufile']['size'][0]."<BR/>"; echo "File Type :".$HTTP_POST_FILES['ufile']['type'][0]."<BR/>"; echo "<img src=\"$path1\" width=\"150\" height=\"150\">"; echo "<P>"; echo "File Name :".$HTTP_POST_FILES['ufile']['name'][1]."<BR/>"; echo "File Size :".$HTTP_POST_FILES['ufile']['size'][1]."<BR/>"; echo "File Type :".$HTTP_POST_FILES['ufile']['type'][1]."<BR/>"; echo "<img src=\"$path2\" width=\"150\" height=\"150\">"; echo "<P>"; echo "File Name :".$HTTP_POST_FILES['ufile']['name'][2]."<BR/>"; echo "File Size :".$HTTP_POST_FILES['ufile']['size'][2]."<BR/>"; echo "File Type :".$HTTP_POST_FILES['ufile']['type'][2]."<BR/>"; echo "<img src=\"$path3\" width=\"150\" height=\"150\">"; /////////////////////////////////////////////////////// // Use this code to display the error or success. $filesize1=$HTTP_POST_FILES['ufile']['size'][0]; $filesize2=$HTTP_POST_FILES['ufile']['size'][1]; $filesize3=$HTTP_POST_FILES['ufile']['size'][2]; if($filesize1 && $filesize2 && $filesize3 != 0) { echo "We have recieved your files"; } else { echo "ERROR....."; } ////////////////////////////////////////////// // What files that have a problem? (if found) if($filesize1==0) { echo "There're something error in your first file"; echo "<BR />"; } if($filesize2==0) { echo "There're something error in your second file"; echo "<BR />"; } if($filesize3==0) { echo "There're something error in your third file"; echo "<BR />"; } ?> Thanks in advance for any help if you need to see a live version of these files i can provide a link I'm trying to work out if in my form my image field, which currently asks the user to upload from their hard drive, can show the contents of a server folder to select an image or upload a new one. Can this be done?? I have a weird kind of problem. I uploaded all upload-directories through FTP which have 777 permissions and owner name 'abc' This means I can access all of them through the codes. But while creating files inside those full permitted directories, the compiler complains for access denied. Meanwhile, a different directory is created with same name whose owner is 'apache' itself and the previous directory is lost. Then I cannot change the permissions of that directory through FTP. I don't if it is apache server's problem itself or not. Or is it a way to define user while creating/editing/deleting files and directories through php code itself? |