dsideal2015 2011-04-20 01:28
浏览 6
已采纳

too long

I am having trouble with this function, I cannot seem to get my file to transfer -> when the file is uploaded into the final location -> What have I missed:

Problem Function:

  public function imageUpload(){
            $this->bExisting = false;
            $location = "includes/images/Gallery/";
            $target = $_FILES['ImagePath']['name']; 
            move_uploaded_file($_FILES['ImagePath']['tmp_name'], $location . $_FILES['ImagePath']['name'] );

  }

Source View

    <form id='imageUpload' action='addimage.php' method= 'post' enctype='multipart/form-data'> 

<fieldset> 

<label for='ImageName'>Image:</label> 

<input type='text' name='ImageName' id='ImageName' value=''  onblur=''/> 

<input type='hidden' name='MAX_FILE_SIZE' value='1000000' /> 

<label for='ImagePath'>Image Path:</label> 

<input type='file' name='ImagePath' id='ImagePath' value='' onblur=''/><input name='submit' id = 'submit' type='submit' value='Image Upload' /> 

</fieldset> 

PHP View:

<?php
ob_flush();
include('includes/session.php');

include('includes/header.php');

include('includes/class/class.form.php');

include('includes/class/class.page.php');


$iPageID = 1; 

if(isset($_GET["PageID"])){

    $iPageID = $_GET["PageID"];
}

$EditedPage = new Page();

$EditedPage->loadPage($iPageID);

$apageInformation = array(); // Information From DB Sticky
$apageInformation["Name"] = $EditedPage->getPageName();
$apageInformation["PageContent"] = $EditedPage->getPageContent();
$EditedPage->getPageContent();

//Sets form information

$Action = "editpage.php?PageID=".$iPageID; // Sets form file

$formEdit = new Form($Action, 'editPage','post','return CheckEditPage();','');

//Sets StickyData

$formEdit->setStickyData($apageInformation);

//Sets the Message

$Message = "";

//If it is set do below

if(isset($_POST["submit"])){

    $formEdit->setStickyData($_POST);

    $formEdit->checkNotEmpty("Name");

    $formEdit->checkNotEmpty("PageContent");


    if($formEdit->getValid() == true){

            $EditedPage->setPageName = $database->escape_value($_POST["Name"]);

            $EditedPage->setPageContent = $database->escape_value($_POST["PageContent"]);

           $EditedPage->updatePage();

        $Message = "Page Updated";

    }else{

        $Message = "You Have An Error Mate";
    }
}


$formEdit->openFieldset();
$formEdit->makeInputBox("Name","Name","CheckInput(this.id);");
$formEdit->makeTextArea("Content", "PageContent", "20","70", "CheckInput(this.id);");
$formEdit->makeSubmitButton("submit","Edit Page");
$formEdit->closeFieldset();
?>
   <section class="left">

    <h1  class="Heading">Edit Page</h1>

        <p class="loginError"><?php echo $Message ?></p>

        <?php echo $formEdit->getHTML(); ?>

    </section> <!-- Section Left End -->

    <section class="right">
        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.
        Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
        It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
        </p>
    </section><!-- Section Right End -->


    <?php include('includes/footer.php')?>
  • 写回答

2条回答 默认 最新

  • doutan8775 2011-04-20 12:39
    关注

    Everytime you have to upload something to a new server, I would suggest to check some points:

    • Make sure to chmod 777 (or make ir writeable) the directory you are going to use. (I would first use 777 and if it works try to put something more restricted)

    • Check the phpinfo to know the correct paths, the post_max_size and the upload_max_filesize. (Usually it does nothing to put that in the html) You'll have to change it in your php.ini or sometimes you'll be allowed by your hosting provider to use the .htaccess

    If these points are checked, I think that maybe it is the path. So I sometimes use this to get a path related to the script you are using. It is not very clean, but it works for me:

    $thepath = substr($_SERVER["SCRIPT_FILENAME"], 0, strrpos ($_SERVER["SCRIPT_FILENAME"], "/")); 
    $location="$thepath/../includes/images/Gallery/"; // if it is in the parent directory of your script, for example.
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 使用yolov5-7.0目标检测报错
  • ¥15 对于这个问题的解释说明
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥20 java在应用程序里获取不到扬声器设备