dtbiszu7724 2016-07-22 01:38
浏览 21

PHP / MySQL上传不起作用

I've got a very basic web app running, and I just need to be able to upload files to the database (and place the file into a separate folder).

I've stripped down the code to the bare bones to try and get it working, but the upload function is failing.

Does anyone know where it could be going wrong?

Note: I've removed the DB username, etc here but it is connecting perfectly.

PAGE WITH FORM:

<form class="order-details" action="engineering/upload.php" method="post" enctype="multipart/form-data">
    <input type="text" placeholder="Client / Customer Name" id="order_client" value="<?php echo $order_client ?>" name="order_client" />
    <input type="hidden" placeholder="Order Number" id="order_no" value="<?php echo $order_no ?>" name="order_no" />
    <input type="file" name="file">
    <input type="submit" />
</form>

UPLOAD.PHP **** Edited **** Unfortunately still not working...

    <?php

    session_start();

    ob_start();
    define('DB_SERVER', 'localhost');
    define('DB_USERNAME', '***');
    define('DB_PASSWORD', '***');
    define('DB_DATABASE', '***');
    $connection = mysql_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD) or die(mysql_error());
    $database = mysql_select_db(DB_DATABASE) or die(mysql_error());


    $order_no = $_POST['order_no'];
$target = "/uploads/"; 
$pic=($_FILES['file']['name']);
$targetfinal = $target . basename( $pic ); 


$sql = "UPDATE orders SET order_files = '$pic' WHERE order_no = '".$order_no."' ";
mysql_query($sql);

if(move_uploaded_file($pic, $targetfinal))  {    

    header ("Location:/edit-order.php?orderid=".$order_no."&upload=success"); 

}  else {   

    echo "Sorry, there was a problem uploading your file."; 

} 

    ?>

Thank you!!!

  • 写回答

1条回答 默认 最新

  • dsgd4654674 2016-07-22 02:43
    关注

    try

    $pic=($_FILES['file']['tmp_name']);

    • and also check the permission of the folder where the file should be uploaded
    • check file size limitation for upload
    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法