Call-911 Posted January 14, 2011 Share Posted January 14, 2011 Hello All, In below script, I'm using another script called "SimpleImage.php" to upload and resize photos for a news site. The problem comes with renaming the photos. I need to name the photo based off of the story id. I have everything right to get the story id, but saving it as the variable is what's confusing me. Here's what I have: <?php include ("newsconnection.php");?> <?php $picturename = $_POST['newstoryid']; include('SimpleImage.php'); $image = new SimpleImage(); $image->load($_FILES['uploaded_image']['tmp_name']); $image->resizeToWidth(300); $image->save('$picturename'); ?> It's the $image->save('$picturename'); line that's messing me up. Any help would be great!! Quote Link to comment Share on other sites More sharing options...
beegro Posted January 14, 2011 Share Posted January 14, 2011 You're using single quotes around a PHP variable $image->save('$picturename'); That treats the string literally instead of as the $picturename value. Try $image->save($picturename); Quote Link to comment Share on other sites More sharing options...
Call-911 Posted January 14, 2011 Author Share Posted January 14, 2011 Would saving it in a directory and as a .jpg be: $image->save('uploadedphotos/'$picturename'.jpg'); or should I include that in the variable? $picturename = 'uploadedphotos/'$_POST['newstoryid']'.jpg'; Quote Link to comment Share on other sites More sharing options...
chronister Posted January 14, 2011 Share Posted January 14, 2011 $image->save('uploadedphotos/'.$picturename.'.jpg'); You have to have the additional periods to properly concatenate the string. Quote Link to comment Share on other sites More sharing options...
Call-911 Posted January 14, 2011 Author Share Posted January 14, 2011 Perfect! Thanks guys! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.