dongxieli3839 2016-12-06 08:12
浏览 99

如何存储文件(用户上传的照片)并通过openshift中的php代码访问它而不会有任何损失

My problem is that everytime when a user uploads photos through my app in openshift it gets lost.When i try to update the code through git,I couldn't find a solution on the net.So I came here for experts advice. i would also appreciate if anyone can point me to an article that does it for php app in openshift.

The problem is simple my user uploaded files are stored in /user/{$_SESSION['id']} folder that is located in repo folder. through research i found that it should be stored in app-root/data folder. If so how can i store user uploaded photos directly there and access it for the user who wants to view it in browser directly like www.testing-pad4u.rhcloud.com/home.php?u={$_SESSION['name']}.

i have no clue on how to do it please help me or point me in the right direction as i'm a total noob to Linux.

after some troubleshooting steps as told in this site https://yuan3y.com/2014/10/setting-up-an-upload-folder-in-openshift/ i modified the code for my own purposes and here is the code:

`#!/bin/bash
# This deploy hook gets executed after dependencies are resolved and the
# build hook has been run but before the application has been started back
# up again.  This script gets executed directly, so it could be python, php,
# ruby, etc.
# This script will create a permanent storage folder on openshift
# put this in .openshift/action_hooks/build

echo ".............pre_build............creating symlinks.................";
if [ ! -d "$OPENSHIFT_DATA_DIR/upload/user" ]; then
    mkdir $OPENSHIFT_DATA_DIR/upload/user
echo "directory user made.";
if [ ! -d "$OPENSHIFT_DATA_DIR/upload/group" ]; then
    mkdir $OPENSHIFT_DATA_DIR/upload/group
    echo "directory group made.";

ln -sf $OPENSHIFT_DATA_DIR/upload/user $OPENSHIFT_REPO_DIR/user
ln -sf $OPENSHIFT_DATA_DIR/upload/group $OPENSHIFT_REPO_DIR/group
echo ".................creating symlinks completed........................";

##source: https://www.openshift.com/forums/openshift/one-newbie-question`

and the error i get is as follows: line 22: syntax error: unexpected end of file remote: An error occurred executing 'gear postreceive' (exit code: 2) remote: Error message: CLIENT_ERROR: Failed to execute action hook 'build'

  • 写回答

1条回答 默认 最新

  • dongmo2324 2016-12-06 15:06
    关注

    Set execution bit on your "build" action hook file.

    Using Git Bash

    git update-index --chmod=+x <your_file>
    

    Then commit and push.

    Here is my action hook as an example.

    #!/bin/bash
    echo ".................Starting 'post_deploy' Action Hook..................................."
    echo ".................attempting 'uploads' setting up symlink........................"
    echo "................................................................................"
    cd $OPENSHIFT_REPO_DIR/thp/static
    ln -s $OPENSHIFT_DATA_DIR/uploads uploads
    echo ".................creating 'uploads' completed........................"
    echo "................................................................................"
    
    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向