Note that there are some explanatory texts on larger screens.

plurals
  1. POCopy file to second directory after upload using PHP
    primarykey
    data
    text
    <p>I am trying to upload an image and at the same time copy the file to another directory where i hope to then create that into a thumbnail size image. </p> <p>The idea is to basically build a dynamic photo album so the output is a loop of images thats gets automatically updated every time someone uploads to it. </p> <p>The main image i can upload without any problems, and the output loop is also easy. But i would love to be able to copy and thumb the image at the same time I upload and insert the file, file name and info to the directory and DB.</p> <p>I have been trying to run a copy after the files uploads and then i was planning to test a Imagick to thumb the second img. But i havent even got around to testing the thumb yet because my copy doesnt work. </p> <p>If all else fails I will just have to use Timthumb but I would expect that to load much slower on the output page. Does anyone have any issues with Timtumb? That would be a hell of a lot easier. :) </p> <p>Basically I have this </p> <pre><code>if(move_uploaded_file($_FILES['thefile']['tmp_name'], 'uploads/' . $_FILES['thefile']['name'])) { $photo_filename = $_FILES['thefile']['name']; $query = "INSERT INTO gallery_photos ( photo_filename ) VALUES ( '{$photo_filename}' )"; $result = mysql_query($query, $connection); $path = 'http://mydomain.com/directory/uploads/'; $fpath = $path.$photo_filename; $dest = 'http://mydomain.com/directory/thumbs/'; $fdest = $dest.$photo_filename; copy($fpath, $fdest); if ($result) { redirect_to("new_photo.php?upload=4"); } else { echo "&lt;p&gt;Dude. Something went wrong!&lt;/p&gt;"; echo "&lt;p&gt;" . mysql_error() . "&lt;/p&gt;"; } } </code></pre> <p>I tried several variations of this, i placed the copy above the SQL and below, I also tried it without the $path/$dest variables i also tried it originally without the full path. But none of them worked. </p> <p>The main pics are being uploaded to the uploads folder though. Its just not getting copied. The DB is getting updated no worries too. </p> <p>Any help will be much appreciated. </p> <p>Cheers</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload