Jump to content

dlebowski

Members
  • Posts

    262
  • Joined

  • Last visited

Everything posted by dlebowski

  1. Here is what I finally had to do to take care of it. Works great now. foreach($_FILES as $files ) { $uploaddir = dirname($_SERVER['SCRIPT_FILENAME'])."/images/".$LotAuctionDate."/"; $arrfile = $files; $uploadfile = $uploaddir . iconv("UTF-8", $target_encoding,basename($arrfile['name'])); if (move_uploaded_file($arrfile['tmp_name'], $uploadfile)) echo "File is valid, and was successfully uploaded.\n"; }
  2. I get this error if I change if() to foreach(): Parse error: syntax error, unexpected ')' on line 544
  3. With the code below, I can get the first Image in my array to upload correctly. I cannot get the others to upload after that. Can someone tell me what is wrong? The array is being generated correctly, but nothing is being grabbed other than first entry. $ImageAuctionDate=$_POST['SelectLotAuctionDate']; echo 'Upload result:<br>'; $uploaddir = dirname($_SERVER['SCRIPT_FILENAME'])."/images/".$ImageAuctionDate."/"; $target_encoding = "ISO-8859-1"; echo '<pre>'; if(count($_FILES) > 0) { $arrfile = pos($_FILES); $uploadfile = $uploaddir . iconv("UTF-8", $target_encoding,basename($arrfile['name'])); if (move_uploaded_file($arrfile['tmp_name'], $uploadfile)) echo "File is valid, and was successfully uploaded.\n"; } else echo 'No files sent. Script is OK!'; echo 'Here is some more debugging info:'; print_r($_FILES); echo "</pre>"; } Result: File is valid, and was successfully uploaded. Here is some more debugging info:Array ( [LotImage1] => Array ( [name] => DSCF3088.JPG [type] => image/jpeg [tmp_name] => /tmp/phpEb0Wvs [error] => 0 [size] => 111168 ) [LotImage2] => Array ( [name] => DSCF3092.JPG [type] => image/jpeg [tmp_name] => /tmp/phpjYo1N6 [error] => 0 [size] => 111525 ) [LotImage3] => Array ( [name] => DSCF3116.JPG [type] => image/jpeg [tmp_name] => /tmp/phpagCTNP [error] => 0 [size] => 113969 ) [LotImage4] => Array ( [name] => DSCF3155.JPG [type] => image/jpeg [tmp_name] => /tmp/phpD3Et3D [error] => 0 [size] => 112006 ) [LotImage5] => Array ( [name] => DSCF3088.JPG [type] => image/jpeg [tmp_name] => /tmp/phpRKJrkw [error] => 0 [size] => 111168 ) [LotImage6] => Array ( [name] => DSCF3187.JPG [type] => image/jpeg [tmp_name] => /tmp/phpujkAkt [error] => 0 [size] => 107119 ) )
  4. Take this out and try it again. Even if you need it, take it out and see if this takes care of it. onchange=\"reload(this.form)\
  5. Do you have to use the <label> tags? Remove those and see if you still have problems.
  6. Yep. I spent 5 hours looking through this thing and don't know how I overlooked that. Thanks as usual!
  7. Nope. It didn't work. I tried that already. Thanks anyway though. Here is the whole script. Keep in mind, everything is working except the thumbnail portion. <?php $ImageAuctionDate=$_GET['ImageAuctionDate']; if(is_dir("images/".$ImageAuctionDate."")) { } else { mkdir("images/".$ImageAuctionDate."", 0777); } echo 'Upload result:<br>'; // At least one symbol should be sent to response!!! $uploaddir = dirname($_SERVER['SCRIPT_FILENAME'])."/images/".$ImageAuctionDate."/"; $target_encoding = "ISO-8859-1"; echo '<pre>'; if(count($_FILES) > 0) { $arrfile = pos($_FILES); $uploadfile = $uploaddir . iconv("UTF-8", $target_encoding,basename($arrfile['name'])); if (move_uploaded_file($arrfile['tmp_name'], $uploadfile)) echo "File is valid, and was successfully uploaded.\n"; } else { echo 'No files sent. Script is OK!'; echo 'Here is some more debugging info:'; print_r($_FILES); echo "</pre>"; } include("dbinfo.inc.php"); mysql_connect("localhost",$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $ImageAuctionDate=$_GET['ImageAuctionDate']; $pathToImages = "../images/".$ImageAuctionDate."/"; $pathToThumbs = "../images/".$ImageAuctionDate."/thumbs/"; $thumbWidth = "75"; function createThumbs( $pathToImages, $pathToThumbs, $thumbWidth ) { // open the directory $dir = opendir( $pathToImages ); // loop through it, looking for any/all JPG files: while (false !== ($fname = readdir( $dir ))) { // parse path for the extension $info = pathinfo($pathToImages . $fname); // continue only if this is a JPEG image if ( strtolower($info['extension']) == 'jpg' ) { echo "Creating thumbnail for {$fname} <br />"; // load image and get image size $img = imagecreatefromjpeg( "{$pathToImages}{$fname}" ); $width = imagesx( $img ); $height = imagesy( $img ); // calculate thumbnail size $new_width = $thumbWidth; $new_height = floor( $height * ( $thumbWidth / $width ) ); // create a new temporary image $tmp_img = imagecreatetruecolor( $new_width, $new_height ); // copy and resize old image into new image imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height ); // save thumbnail into a file imagejpeg( $tmp_img, "{$pathToThumbs}{$fname}" ); } } // close the directory closedir( $dir ); } createThumbs("images/".$ImageAuctionDate."/","images/".$imageAuctionDate."/thumbs/",100); ?>
  8. It is coming over from a form and GET does work because the beginning portion of my code works fine using GET. The two pieces I have provided are just snippets of a larger script.
  9. I have spent all day working on this and cannot figure this out. Here is the error that I get: "function.imagejpeg</a>]: Unable to open 'images//thumbs/SBCB9196A.jpg'". This would indicate that I am having a problem with getting a value for the $pathToThumbs variable. No matter what I assign the $Date variable, I cannot get it to find it. Can someone please let me know if my syntax is wrong? Thanks for your help. $Date=$_GET['Date']; //Create variable $pathToThumbs = "../images/".$Date."/thumbs/"; // save thumbnail into a file imagejpeg( $tmp_img, "{$pathToThumbs}{$fname}" );
  10. Not a problem. Thanks for the suggestion. I have been struggling with this for a week or so now!
  11. I want them to be able to run it from within the application. Are you suggesting just creating a link from within the application for them to click on and allow them to upload their images into the directory through the app? I have thought about this a little, but have heard their is security issues with doing this. I guess I could force them to enter in their login and password again. Once they click on the link. Is this what you had in mind?
  12. I need my client to be able to upload them once they log into the site. FTP would be difficult for them to use.
  13. Thanks man. I think this will be perfect. The next question I have for you is how do you go about uploading hundreds of images at once? Do you use a java applet to upload an entire directory? Thanks again!
  14. Does anyone know of a way to automatically scale an image and then copy that image to a new directory following an import? My image import works great, but I need it to create a copy that is scaled down and then save it to a different directory. Any help would be appreciated. Thanks as usual for any help you can provide! Ryan
  15. Here is what my code looks like. For example, often a file being imported may not want to populate $column1. But I have to leave it in there because the file I try importing at a later date may actually need that column. Let me know if I need to elaborate more. Thanks. $import="INSERT into lots(LotID,$column1,$column2,$column3,$column4,LotPayment,Online,Absentee,$column5,Date, $column6, $column7)"; $import .=" values('', '" . cleancvs($data[0]) . "','" . cleancvs($data[1]) . "',"; $import .= " '" . cleancvs($data[2]) . "','" . cleancvs($data[3]) . "','$lotpayment', '$online', '','" . cleancvs($data[4]) . "','$dateimport', '" . cleancvs($data[5]) . "', '" . cleancvs($data[6]) . "')"; mysql_query($import) or die(mysql_error());
  16. So are you referring to the field in the database? Make sure it has a default value?
  17. I am importing a .csv file and it works great until i have to ignore a column in the file. How do I setup the insert query to ignore that column? Through the import the user selects which fields in the .csv file correspond with the tables in the database using variables. On occasion they have a field in the file that needs to be ignored. Thanks for the help. Change this: INSERT into table_name (column1, column2....) values (value1, value2...); To something like this: INSERT into table_name (IGNORE, CustomerID....) values (value1, value2...);
  18. Thanks for all your suggestions. I will have a look at these. I just know of a site that uses an ActiveX control to ask you to either select a folder or select a file and it populates a list. You then just click on submit and it pops up a status bar that shows the status of each file as it is being uploaded. It is perfect for what I'm trying to do.
  19. Thanks for the response. I saw that option and that may be my only solution. I really would like them to just be able to select the directory, the contents of the directory are displayed in the page, then the user clicks upload to load them all. That would be ideal. Anyone else with suggestions would be appreciated! Thanks again. Ryan
  20. What I want to do is allow my users to be able to upload an entire directory worth of images to the server. So for example, the form will ask them for either a file to import or for a directory where the images reside. It will then proceed to upload each image individually until the directory is empyt. Is this possible? Thanks for you help. Ryan
  21. Below is a couple of snippets of code that I have for modifying the date format from MySQL and it works great. The problem I am running into is later in the code I need to call the $AuctionDate variable to query the data field in another table. This won't work because the format has been modified using date_FORMAT. How do I convert it back to the MySQL date format so I can properly query the database. Thank for your help as usual! Query converting MySQL date format: $query="SELECT date_FORMAT(AuctionDate, '%M %e, %Y') as newdate, AuctionDescription, AuctionTitle FROM auctions WHERE AuctionDate >= NOW() ORDER BY AuctionDate"; $AuctionDate=mysql_result($result,$i,"newdate"); Need to change $AuctionDate back to MySQL date format for the query below: $query="SELECT AuctionImageDate FROM AuctionImages WHERE AuctionImageDate=$AuctionData";
  22. I fixed it. Actually it appears to work perfect. Thanks to both of you for helping me through this. Ryan
  23. I went ahead and implemented the changes. It doesn't error out now, but nothing imports. I will keep playing with the code. Thanks for helping me out.
  24. I was looking at this earlier, but I'm not sure where to put that in my code. I will give it a whirl. Ryan
  25. Strip slashes will only remove them when I call the data again using a SELECT query correct? What about just removing any apostrophe at all from my import before it goes in. If that is possible, that would probably work for me.
×
×
  • 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.