Jump to content

Code Not Working...


Warptweet

Recommended Posts

I have an uploader form. And theres a problem, it gives me an error.

go to www.warptweet.com/uploadflash.php
It will take you to a form, try uploading a .swf (flash) file, and it will give you an error.
Here is the code
[code]<?php
if (($_FILES["file"]["type"] == "application/x-shockwave-flash") &&
  ($_FILES["file"]["size"] < $_POST['MAX_FILE_SIZE'])) {
  echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
  echo "Uploading " . $_FILES["file"]["name"];
  echo " (" . $_FILES["file"]["type"] . ", ";
  echo ceil($_FILES["file"]["size"] / 1024) . " Kb).<br />";

  if (file_exists("uploads/" . $_FILES["file"]["name"])) {
    echo $_FILES["file"]["name"] . " already exists.  ";
    echo "Please delete the destination file and try again.";
  } else {
    move_uploaded_file($_FILES["file"]["tmp_name"],
    "uploads/" . $_FILES["file"]["name"]);
    echo "File has been stored in your uploads directory.";
    $flashname = $_POST['flashname'];
    $flashauthor = $_POST['flashauthor'];
    $flashdescription = $_POST['flashdescription'];
    $ourFileName = $_POST['uploadedfile'];
    $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
    rename($ourFileName, substr($ourFileName, 0, strrpos($ourFileName,'.')).'.txt');
    fclose($ourFileName);
    $fh = fopen($ourFileName, 'w') or die("can't open file");
    $stringData = $flashname;
    fwrite($fh, $stringData);
    fclose($fh);
  }

} else
  echo "Warptweet.com Error Returned: Only .swf flash files under 20MB may be uploaded.";
?>

[/code]

Can anyone tell me whats wrong? Or improvise on my code?
Link to comment
https://forums.phpfreaks.com/topic/32822-code-not-working/
Share on other sites

I am absolutely clueless as to why you would want to change .swf to .txt and then add some string to it, but hey, it's your party:

[code]<?php
$file = "uploads/" . $_FILES["file"]["name"];
move_uploaded_file($_FILES["file"]["tmp_name"], $file);

$newFile = substr($file, 0, strrpos($file,'.')).'.txt';
rename($file, $newFile);

$fh = fopen($newFile, 'w') or die("can't open file");
fwrite($fh, $_POST['flashname']);
fclose($fh);
?>[/code]
Link to comment
https://forums.phpfreaks.com/topic/32822-code-not-working/#findComment-152826
Share on other sites

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.