Jump to content

Problem saving into folder name declared as variable.vdxdf


sluke101

Recommended Posts

Hiya I'm having trouble modifying getting the below code to work. It's basicaly the php code to a flash picture upload tutorial.

 

The problem is with the $uploadDirectory variable. If I change the $fVar1 to the name of a folder in my localhost the file will be saved correctly, however if it stays as $fVar1 the file doesn't save? Any idea what might be wrong?

 

  1. <?php

  2. 

  3.    $fVar1 = $_POST['id'];

  4.    $fVar2 = $_POST['filename'];

  5.    $fVar3 = "test";

  6. 

  7.    mkdir("$fVar1");

  8. 

  9.  if (is_uploaded_file($_FILES['Filedata']['tmp_name'])){

  10. 

  11.    $uploadDirectory="$fVar1/";

  12.    $uploadFile=$uploadDirectory.basename($_FILES['Filedata']['name']);

  13. 

  14.    copy($_FILES['Filedata']['tmp_name'], $uploadFile);

  15.         

  16.  }

  17. ?>

 

 

Cheers in advance

 

Sluke

try

 

  1. <?php

  2.

  3.    $fVar1 = $_POST['id'];

  4.    $fVar2 = $_POST['filename'];

  5.    $fVar3 = "test";

  6.

  7.    mkdir($fVar1);

  8.

  9.  if (is_uploaded_file($_FILES['Filedata']['tmp_name'])){

  10.

  11.    $uploadDirectory="$fVar1" . "/";

  12.    $uploadFile=$uploadDirectory.basename($_FILES['Filedata']['name']);

  13.

  14.    copy($_FILES['Filedata']['tmp_name'], $uploadFile);

  15.       

  16.  }

  17. ?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.