donglu8344812 2014-09-17 18:30
浏览 22

如何克隆TMP上传的文件?

I want to change text in my text.txt uploaded for each link, so I upload TEXT.TXT and that results in 3 text.txt in archive like

    $namefil_text = $_FILES["myfile_text"]["name"];
    $typefil_text = $_FILES["myfile_text"]["type"];
    $sizefil_text = $_FILES["myfile_text"]["size"];
    $tempfil_text = $_FILES["myfile_text"]["tmp_name"];
    $errorfil_text = $_FILES["myfile_text"]["error"];

    $fisi_text1 = file_put_contents($tempfil_text,str_replace('link_gsh',$video_link1,file_get_contents($tempfil_text)));
    $fisi_text2 = file_put_contents($tempfil_text,str_replace('link_gsh',$video_link2,file_get_contents($tempfil_text)));
    $fisi_text3 = file_put_contents($tempfil_text,str_replace('link_gsh',$video_link3,file_get_contents($tempfil_text)));



if ($zip1->open("./videos/".$numefiermare1, ZIPARCHIVE::CREATE)!==TRUE) {
                            exit("Cannot open <$numefiermare1>
");
                        }
                        else
                        {
                            $zip3->addFile($tempfil,$namefil);
                            $zip3->addFile($fisi_text1,$namefil_text);
                            $zip3->close();

}
if ($zip2->open("./videos/".$numefiermare2, ZIPARCHIVE::CREATE)!==TRUE) {
                            exit("Cannot open <$numefiermare1>
");
                        }
                        else
                        {
                            $zip3->addFile($tempfil,$namefil);
                            $zip3->addFile($fisi_text2,$namefil_text);
                            $zip3->close();

}
if ($zip3->open("./videos/".$numefiermare3, ZIPARCHIVE::CREATE)!==TRUE) {
                            exit("Cannot open <$numefiermare3>
");
                        }
                        else
                        {
                            $zip3->addFile($tempfil,$namefil);
                            $zip3->addFile($fisi_text3,$namefil_text);
                            $zip3->close();

}

So now comes the question... if I run the code like that only one archive gets the txt file OR do all of them get the text file with same link? As you can see, I try to replace that syntax with link from the form.

How can I fix that ? Thanks !

  • 写回答

1条回答 默认 最新

  • dongrongdao8902 2014-12-19 20:37
    关注

    I haven't really understood what you're really asking, but in all else blocks, you're referencing $zip3 which will not be open in the first two cases. You need to use $zip1 and $zip2 in those else blocks instead. You should also format your code nicely: you will spot errors like these more easily in tidy code.

    评论

报告相同问题?

悬赏问题

  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线