PHP Classes

upload file twice with different extensions

Recommend this page to a friend!

      JSON File Upload  >  All threads  >  upload file twice with different...  >  (Un) Subscribe thread alerts  
Subject:upload file twice with different...
Summary:upload file twice with different extensions. How to modify?
Messages:2
Author:David Schmitz
Date:2010-06-02 13:18:46
Update:2010-06-02 13:20:27
 

  1. upload file twice with different...   Reply   Report abuse  
Picture of David Schmitz David Schmitz - 2010-06-02 13:18:46
Hello,

great class, that you wrote.

I am using the script to give users the chance upload some images to my server.
The thing is, that I need all images as jpg and as gif. So I was trying to modify the script, that it automatically uploads the file two times, with different extesions.

Here is, what I changed in upload1.php

my changes are in the first lines of that script:

session_start();
require_once "upload_class.php";
$_SESSION['number'] = $_SESSION['number'] +1;
for ($two = 1; $two<2; $two++)
{
if ($two == 1) {$extension = ".gif";} else {$extension = ".jpg";}
$new_name = $_SESSION['object']."_".$_SESSION['client']."_".$_SESSION['number'].$extension;
$upload_class = new Upload_Files;
$upload_class -> temp_file_name = trim($_FILES['userfile']['tmp_name']);
$upload_class -> file_name = $new_name;//.trim(strtolower($_FILES['userfile']['name']));

So, I am renaming the files and giving them the extension jpg and gif.

The problem is, that the second run of the loop doesn't work.

Could you tell me, how to do it?

Thanks,
David

  2. Re: upload file twice with different...   Reply   Report abuse  
Picture of David Schmitz David Schmitz - 2010-06-02 13:20:28 - In reply to message 1 from David Schmitz
edit:

of course, my loop starts with ($two = 1; $two <=2 ...)