Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6182983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:17:22+00:00 2026-05-24T01:17:22+00:00

I let the user upload an image. It then creates a temp file but

  • 0

I let the user upload an image. It then creates a temp file but I don’t want to move it to a permanent address yet because I want to take them to cropphoto.php where they can create a thumbnail from it. If they exit out of the window before this I don’t want it to be saved.

How would I pass the temporary image from the following script:

<?php 
include_once '../dbconnect.php'; 
$protocol = !empty($_SERVER['HTTPS']) ? 'https://' : 'http://';
$domain = $protocol. $_SERVER['SERVER_NAME'];

function findexts ($filename) {
    $filename = strtolower($filename) ;
    $exts = split("[/\\.]", $filename) ;
    $n = count($exts)-1;
    $exts = $exts[$n];
    return $exts;
}

$SubcatID = $_POST['SubcatID'];
if (empty($SubcatID)){
    $SubcatID = -1;
}

$ext = findexts ($_FILES['photo']['name']) ; 
if ($ext == "jpg" || $ext == "jpeg") {
    $return = 'cropphoto.php?PhotoID='.urlencode($_FILES['photo']['name']);
    header("Location: $return");
} 
else {
    echo "ERROR: The image must be a JPEG";
    exit;
}
?> 

The current url paramater im using just passes the image name but I can’t find the temp folder it is in.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T01:17:23+00:00Added an answer on May 24, 2026 at 1:17 am

    PHP will auto-delete the file when the script exits, unless you take steps to preserve it. I’d suggest moving the file to a staging directory with some unique filename. You pass this filename on to the crop script. The crop script does whatever it has to, and then moves the file to its final destination.

    To deal with orphaned files (e.g. the user closed the window), you can have a timed job do a cleanup in the staging directory. Any files older than a certain period (10 minutes, 30 minutes, etc…) get erased. There’s ways to have a browser tell the server that it’s being shut down, but they’re not reliable, so you’d still need this scheduled job to do a proper cleanup.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to let a user upload a PNG-file with alpha transparency and have
So I have a file for constants. I want to let user define them
I want to let the user draw on an image in a browser. In
here is a site http://www.lyrkjsw.gov.cn that can let the registered user to upload file
I want let user to upload images to server add some info (like description,
I am trying to let the user upload an image from my facebook app
I want the file input will automatic upload my image without enter any submit
I would like for a user to upload an image to a file in
My plan is to let a user to upload an excel file, once uploaded
I want to let the user download the current content of a textarea into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.